getborg 0.0.109 → 0.0.118

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 (115) hide show
  1. package/dist/{BunPtyAdapter-B8CZTUkK.mjs → BunPtyAdapter-kPTUT2mb.mjs} +3 -3
  2. package/dist/{Config-DFbx48ty.mjs → Config-DvH5tPG0.mjs} +2 -2
  3. package/dist/{FetchHttpClient-DEMRQKIB.mjs → FetchHttpClient-C-jciW95.mjs} +3 -3
  4. package/dist/{FileSystem-41Cezpd1.mjs → FileSystem-NX0EtGtm.mjs} +109 -3
  5. package/dist/{Mime-D2854Tqo.mjs → Mime-C6O17O_3.mjs} +5 -5
  6. package/dist/{NodeHttpIncomingMessage-BqU9AHA2.mjs → NodeHttpIncomingMessage-CylGKvlB.mjs} +4 -4
  7. package/dist/{NodeHttpServer-C-eqvdR4.mjs → NodeHttpServer-EarHJJzn.mjs} +9 -9
  8. package/dist/{NodePtyAdapter-BdtcaYPg.mjs → NodePtyAdapter-C6ioPYk6.mjs} +5 -5
  9. package/dist/{NodeServices-pD4zkANr.mjs → NodeServices-C18DO3cx.mjs} +6 -6
  10. package/dist/{NodeSqliteClient-BIVa5aFu.mjs → NodeSqliteClient-CWkKfsSo.mjs} +5 -5
  11. package/dist/{NodeStream-BjNgA5_1.mjs → NodeStream-1N7oXzTp.mjs} +3 -3
  12. package/dist/{Path-D8BPsRhh.mjs → Path-ZDpyUmZ1.mjs} +2 -2
  13. package/dist/{PtyAdapter-B9zQDp9u.mjs → PtyAdapter-DSEyRij4.mjs} +2 -2
  14. package/dist/{Schema-DkAVclKk.mjs → Schema-CA_wFfhH.mjs} +141 -4
  15. package/dist/{SqlClient-JflyUX7a.mjs → SqlClient-Cusaqpaw.mjs} +3 -3
  16. package/dist/bin.mjs +7894 -2484
  17. package/dist/{borgTelemetryNode-B0vVayda.mjs → borgTelemetryNode-CHLcRFOW.mjs} +6 -6
  18. package/dist/client/.vite/manifest.json +330 -330
  19. package/dist/client/assets/ArrowRight-CgvCTAzu.js +2 -0
  20. package/dist/client/assets/ArrowSquareOut-C1CwJQ7R.js +2 -0
  21. package/dist/client/assets/ArrowsClockwise-CBwAQTtQ.js +2 -0
  22. package/dist/client/assets/CaretLeft-Bk0n02vc.js +2 -0
  23. package/dist/client/assets/ChatMarkdown-BhfpBJaq.js +249 -0
  24. package/dist/client/assets/DesignWorkspace-okkekyBu.js +3 -0
  25. package/dist/client/assets/DiffPanel-Dn_Or9fx.js +2 -0
  26. package/dist/client/assets/DiffWorkerPoolProvider-Hp3trMBG.js +10 -0
  27. package/dist/client/assets/DocxPreview-DHnzhQMX.js +17 -0
  28. package/dist/client/assets/{FilePreviewPanel-CeAwd87I.js → FilePreviewPanel-KOVwBhPe.js} +19 -19
  29. package/dist/client/assets/HtmlPreview-I3xV5YgS.js +2 -0
  30. package/dist/client/assets/PdfPreview-CjWrZkCM.js +3 -0
  31. package/dist/client/assets/PptxPreview-D4YsFq_s.js +3 -0
  32. package/dist/client/assets/PreviewPanel-CKieJ-9L.js +2 -0
  33. package/dist/client/assets/PullRequestCodeTab-DbUx3FWB.js +6 -0
  34. package/dist/client/assets/{PullRequestReactions-BWjOU4KY.js → PullRequestReactions-BSI_Qt4L.js} +4 -4
  35. package/dist/client/assets/{RightPanelResizeHandle-DZdzK7y3.js → RightPanelResizeHandle-DBci-Ee2.js} +2 -2
  36. package/dist/client/assets/VirtualizedFile-VSzhLWFM.js +2 -0
  37. package/dist/client/assets/XlsxPreview-BnnrdNes.js +3 -0
  38. package/dist/client/assets/accountData-C4ZvicpJ.js +16 -0
  39. package/dist/client/assets/assetUrls-C2vkiSgX.js +2 -0
  40. package/dist/client/assets/browserHistoryStore-CIr_OQCq.js +4 -0
  41. package/dist/client/assets/browserRecording-BmG6q-H4.js +2 -0
  42. package/dist/client/assets/clientPersistenceStorage-BlYjZvCd.js +2 -0
  43. package/dist/client/assets/combobox-uXzVxkLc.js +2 -0
  44. package/dist/client/assets/composerMentionDrag-DTGN7WcV.js +2 -0
  45. package/dist/client/assets/designCanvas.logic-DtK3Ht6X.js +8 -0
  46. package/dist/client/assets/designOpenFileContext-DCJpUleA.js +2 -0
  47. package/dist/client/assets/diffFileContents-CFjzWK4l.js +248 -0
  48. package/dist/client/assets/empty-tcpR9LH8.js +2 -0
  49. package/dist/client/assets/entities-Da-AvwsX.js +2 -0
  50. package/dist/client/assets/env-71Gq9H0m.js +2 -0
  51. package/dist/client/assets/{index-BKWzfr1Y.js → index-DraeEDbf.js} +3 -3
  52. package/dist/client/assets/input-BRLXkmUH.js +2 -0
  53. package/dist/client/assets/{lib-DyhHMOev.js → lib-ay4Y8Jpt.js} +2 -2
  54. package/dist/client/assets/main-Bn8Ylf8R.js +161 -0
  55. package/dist/client/assets/main-YscGsfgO.css +2 -0
  56. package/dist/client/assets/{pdf-C_AIVI51.js → pdf-BH4RlEy2.js} +2 -2
  57. package/dist/client/assets/popover-DTprsoPQ.js +2 -0
  58. package/dist/client/assets/{pptxDocument-CHL8asXA.js → pptxDocument-ifTk53yH.js} +2 -2
  59. package/dist/client/assets/projectFilesQueryState-CD_JXBj5.js +2 -0
  60. package/dist/client/assets/queries-D1AwaR_5.js +2 -0
  61. package/dist/client/assets/scroll-area-j6QV0udq.js +1634 -0
  62. package/dist/client/assets/session-BaysTZDD.js +67 -0
  63. package/dist/client/assets/spinner-DHhZaoFg.js +2 -0
  64. package/dist/client/assets/textarea-BB3euU4O.js +5 -0
  65. package/dist/client/assets/toggle-DwBa6pBo.js +2 -0
  66. package/dist/client/assets/toggle-group-BU7-0DcW.js +2 -0
  67. package/dist/client/assets/useWorkspaceMutationRefresh-DLI4brDf.js +2 -0
  68. package/dist/client/assets/utils-DgzD4MA_.js +30 -0
  69. package/dist/client/assets/{xlsxDocument-ANMZ6ewU.js → xlsxDocument-DwhEMpfP.js} +2 -2
  70. package/dist/client/index.html +1 -1
  71. package/dist/service-launcher.mjs +1 -1
  72. package/package.json +1 -1
  73. package/dist/client/assets/ArrowRight-BOicMyF9.js +0 -2
  74. package/dist/client/assets/ArrowSquareOut-D7Y2Tt3L.js +0 -2
  75. package/dist/client/assets/ArrowsClockwise-DycxhEkt.js +0 -2
  76. package/dist/client/assets/CaretLeft-CDMA3Uas.js +0 -2
  77. package/dist/client/assets/ChatMarkdown-Cl8M9HCx.js +0 -247
  78. package/dist/client/assets/DesignWorkspace-DBL7AxwS.js +0 -3
  79. package/dist/client/assets/DiffPanel-BJ-Ix_7K.js +0 -2
  80. package/dist/client/assets/DiffWorkerPoolProvider-_R9JGgmp.js +0 -10
  81. package/dist/client/assets/DocxPreview-BFCC5VXn.js +0 -17
  82. package/dist/client/assets/HtmlPreview-BpBdu9_j.js +0 -2
  83. package/dist/client/assets/PdfPreview-CeECoD5z.js +0 -3
  84. package/dist/client/assets/PptxPreview-u6gN3x3Z.js +0 -3
  85. package/dist/client/assets/PreviewPanel-BVJp3UI5.js +0 -2
  86. package/dist/client/assets/PullRequestCodeTab-Bxx0Vkdn.js +0 -6
  87. package/dist/client/assets/VirtualizedFile-CyAKSbzc.js +0 -2
  88. package/dist/client/assets/XlsxPreview-CaykIFrZ.js +0 -3
  89. package/dist/client/assets/assetUrls-BBFxUocf.js +0 -2
  90. package/dist/client/assets/browserHistoryStore-K9gWOOUq.js +0 -2
  91. package/dist/client/assets/browserRecording-DrMz1iOt.js +0 -4
  92. package/dist/client/assets/clientPersistenceStorage-DSC61yLx.js +0 -2
  93. package/dist/client/assets/combobox-C4C8XR-w.js +0 -6
  94. package/dist/client/assets/composerMentionDrag-D06cCeGC.js +0 -2
  95. package/dist/client/assets/designCanvas.logic-DuuhotDy.js +0 -8
  96. package/dist/client/assets/designOpenFileContext-CCQs4ovB.js +0 -2
  97. package/dist/client/assets/diffFileContents-Bj3q_jc2.js +0 -248
  98. package/dist/client/assets/empty-DynqTxIR.js +0 -2
  99. package/dist/client/assets/entities-dwE_i4XM.js +0 -2
  100. package/dist/client/assets/env-DgM3kOA4.js +0 -2
  101. package/dist/client/assets/input-Q4KA45-f.js +0 -2
  102. package/dist/client/assets/main-CI0aXqkB.css +0 -2
  103. package/dist/client/assets/main-DFDCV-Ns.js +0 -145
  104. package/dist/client/assets/popover-CXGEm4M0.js +0 -2
  105. package/dist/client/assets/projectFilesQueryState-7mFyaRdj.js +0 -2
  106. package/dist/client/assets/queries-x5LGu_Fy.js +0 -2
  107. package/dist/client/assets/scroll-area-D8MfzXjN.js +0 -1630
  108. package/dist/client/assets/session-DIGL5_Nm.js +0 -67
  109. package/dist/client/assets/spinner-CwxxMzkd.js +0 -2
  110. package/dist/client/assets/textarea-DdNchuIO.js +0 -5
  111. package/dist/client/assets/toggle-CmeCFqd7.js +0 -2
  112. package/dist/client/assets/toggle-group-iEMUfMdW.js +0 -2
  113. package/dist/client/assets/useLocalStorage-2W_I13tQ.js +0 -16
  114. package/dist/client/assets/useWorkspaceMutationRefresh-YuIxWftk.js +0 -2
  115. package/dist/client/assets/utils-D0kLIGeh.js +0 -30
@@ -1,10 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{Ha as t,Na as n,Oa as r,a as i}from"./useLocalStorage-2W_I13tQ.js";import{Bo as a,t as o,wo as s}from"./utils-D0kLIGeh.js";import{xt as c}from"./textarea-DdNchuIO.js";import{$ as l,$t as u,A as d,At as f,C as p,Cn as m,D as h,Dt as g,E as _,Et as v,F as y,Ft as b,H as x,I as S,J as C,K as w,L as T,M as E,N as D,Nt as O,O as k,P as A,Pt as j,Q as M,R as N,S as P,Sn as ee,St as te,T as ne,U as re,V as ie,W as ae,X as F,Y as oe,Z as I,_ as se,_t as ce,an as le,at as ue,b as de,bn as fe,c as pe,ct as me,d as he,et as ge,fn as _e,ft as L,g as ve,gn as ye,gt as be,h as xe,hn as R,ht as z,in as Se,it as Ce,j as we,jt as Te,k as Ee,l as De,ln as Oe,lt as B,m as ke,mt as Ae,nt as V,ot as H,p as je,pn as Me,pt as Ne,q as Pe,rn as Fe,rt as Ie,s as Le,st as Re,tt as U,u as ze,ut as W,v as Be,w as Ve,wn as He,x as Ue,xn as We,y as Ge}from"./scroll-area-D8MfzXjN.js";import{t as Ke}from"./env-DgM3kOA4.js";import{t as G}from"./lib-BpnzBIoA.js";var K=s(),q=a();function J(e){let t=(0,K.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=o(`relative overflow-hidden rounded-sm bg-muted [--skeleton-highlight:--alpha(var(--color-white)/64%)] after:absolute after:inset-0 after:animate-skeleton after:bg-[linear-gradient(120deg,transparent_40%,var(--skeleton-highlight),transparent_60%)] motion-reduce:after:content-none dark:[--skeleton-highlight:--alpha(var(--color-white)/4%)]`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,q.jsx)(`div`,{className:i,"data-slot":`skeleton`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function qe(e){return o(`flex items-center justify-between gap-2`,e===`embedded`?`px-2`:`px-4`,Ke&&e!==`sheet`&&e!==`embedded`?`drag-region h-[52px] border-b border-border wco:h-[env(titlebar-area-height)] wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)]`:`flex h-10 min-h-10 shrink-0 items-center border-b border-border/60 bg-background in-data-[preview-panel-mode=inline]:mb-3 in-data-[preview-panel-mode=inline]:h-7 in-data-[preview-panel-mode=inline]:min-h-7 in-data-[preview-panel-mode=inline]:border-b-transparent`)}function Je(e){let t=(0,K.c)(10),n=Ke&&e.mode!==`sheet`&&e.mode!==`embedded`,r=e.mode===`inline`?`w-[42vw] min-w-[360px] max-w-[560px] shrink-0 border-l border-border`:`w-full`,i;t[0]===r?i=t[1]:(i=o(`flex h-full min-w-0 flex-col bg-background`,r),t[0]=r,t[1]=i);let a;t[2]!==e.header||t[3]!==e.mode||t[4]!==n?(a=n?(0,q.jsx)(`div`,{className:qe(e.mode),children:e.header}):(0,q.jsx)(`div`,{className:qe(e.mode),"data-surface-subheader":!0,children:e.header}),t[2]=e.header,t[3]=e.mode,t[4]=n,t[5]=a):a=t[5];let s;return t[6]!==e.children||t[7]!==i||t[8]!==a?(s=(0,q.jsxs)(`div`,{className:i,children:[a,e.children]}),t[6]=e.children,t[7]=i,t[8]=a,t[9]=s):s=t[9],s}function Ye(e){let t=(0,K.c)(9),{titleClassName:n}=e,r,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,q.jsx)(`div`,{className:`flex size-5 shrink-0 items-center justify-center`,children:(0,q.jsx)(J,{className:`size-2.5 rounded-[2px]`})}),i=(0,q.jsx)(J,{className:`size-5 shrink-0 rounded-md`}),t[0]=r,t[1]=i):(r=t[0],i=t[1]);let a;t[2]===n?a=t[3]:(a=o(`h-3 rounded-full`,n),t[2]=n,t[3]=a);let s;t[4]===a?s=t[5]:(s=(0,q.jsx)(J,{className:a}),t[4]=a,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,q.jsx)(J,{className:`h-3 w-5 rounded-full`}),(0,q.jsx)(J,{className:`h-3 w-5 rounded-full`})]}),t[6]=c):c=t[6];let l;return t[7]===s?l=t[8]:(l=(0,q.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2 pr-3`,children:[r,i,s,c]}),t[7]=s,t[8]=l),l}function Xe(e){let t=(0,K.c)(5),{contentClassName:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,q.jsx)(J,{className:`h-2.5 w-5 shrink-0 rounded-full`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=o(`h-2.5 rounded-full`,n),t[1]=n,t[2]=i);let a;return t[3]===i?a=t[4]:(a=(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r,(0,q.jsx)(J,{className:i})]}),t[3]=i,t[4]=a),a}function Ze(e){let t=(0,K.c)(10),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,q.jsx)(Ye,{titleClassName:`w-1/2 max-w-64`}),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,q.jsxs)(`div`,{className:`flex h-6 items-center gap-2 px-2 pr-3`,children:[(0,q.jsx)(`div`,{className:`h-px flex-1 bg-border/40`}),(0,q.jsx)(J,{className:`h-2.5 w-24 rounded-full`}),(0,q.jsx)(`div`,{className:`h-px flex-1 bg-border/40`})]}),t[1]=r):r=t[1];let i,a,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,q.jsxs)(`div`,{className:`space-y-2 px-3 py-2`,children:[(0,q.jsx)(Xe,{contentClassName:`w-2/3`}),(0,q.jsx)(Xe,{contentClassName:`w-4/5`}),(0,q.jsx)(Xe,{contentClassName:`w-3/5`})]}),a=(0,q.jsx)(Ye,{titleClassName:`w-2/5 max-w-52`}),o=(0,q.jsx)(Ye,{titleClassName:`w-3/5 max-w-72`}),t[2]=i,t[3]=a,t[4]=o):(i=t[2],a=t[3],o=t[4]);let s;t[5]===e.label?s=t[6]:(s=(0,q.jsx)(`span`,{className:`sr-only`,children:e.label}),t[5]=e.label,t[6]=s);let c;return t[7]!==e.label||t[8]!==s?(c=(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-hidden bg-background`,role:`status`,"aria-live":`polite`,"aria-label":e.label,children:[n,r,i,a,o,s]}),t[7]=e.label,t[8]=s,t[9]=c):c=t[9],c}function Qe({hunkIndex:e,lineIndex:t,conflictIndex:n}){return`merge-conflict-action-${e}-${t}-${n}`}function $e(e,t){let n=t.hunks[e.hunkIndex];if(n!=null)return{hunkIndex:e.hunkIndex,lineIndex:et(n,e.startContentIndex)}}function et(e,t){let n=e.unifiedLineStart;for(let r=0;r<t;r++){let t=e.hunkContent[r];n+=t.type===`context`?t.lines:t.deletions+t.additions}return n}function tt({fileDiff:e,actions:t,renderCustomHeader:n,renderHeaderPrefix:r,renderHeaderFilenameSuffix:i,renderHeaderMetadata:a,renderAnnotation:o,renderGutterUtility:s,renderMergeConflictUtility:c,lineAnnotations:l,getHoveredLine:u,getInstance:d}){let f=n?.(e),p=r?.(e),m=i?.(e),h=a?.(e);return(0,q.jsxs)(q.Fragment,{children:[f==null?(0,q.jsxs)(q.Fragment,{children:[p!=null&&(0,q.jsx)(`div`,{slot:`header-prefix`,children:p}),m!=null&&(0,q.jsx)(`div`,{slot:`header-filename-suffix`,children:m}),h!=null&&(0,q.jsx)(`div`,{slot:`header-metadata`,children:h})]}):(0,q.jsx)(`div`,{slot:Oe,children:f}),o!=null&&l?.map((e,t)=>(0,q.jsx)(`div`,{slot:O(e),children:o(e)},t)),t!=null&&c!=null&&d!=null&&t.map(t=>{if(t==null)return;let n=nt(t,e);return(0,q.jsx)(`div`,{slot:n,style:b,children:c(t,d)},n)}),s!=null&&(0,q.jsx)(`div`,{slot:`gutter-utility-slot`,style:j,children:s(u)})]})}function nt(e,t){let n=$e(e,t);return n==null?void 0:Qe({hunkIndex:n.hunkIndex,lineIndex:n.lineIndex,conflictIndex:e.conflictIndex})}var rt=`/dev/null`;function Y(e,t,n,r=!1){if(e===null&&t===null)throw Error(`parseDiffFromFile: You must pass oldFile, newFile, or both`);let i=e??it(),a=t??it(),o=Fe(oe(i.name,a.name,i.contents,a.contents,i.header,a.header,n),{cacheKey:(()=>{let n=e?.cacheKey??e?.name,r=t?.cacheKey??t?.name;return n!=null&&r!=null?n+`:`+r:n??r})(),oldFile:i,newFile:a,throwOnError:r});if(o==null)throw Error(`parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?`);e===null?(o.type=`new`,o.prevName=void 0):t===null&&(o.type=`deleted`,o.prevName=void 0);let s=t?.lang??(t===null?e?.lang:void 0);return s!=null&&(o.lang=s),o}function it(){return{name:rt,contents:``}}function X(e,t){let n=Y({name:e.prevName??e.name,contents:e.deletionLines.join(``)},{name:e.name,contents:e.additionLines.join(``),lang:e.lang},t);return{hunks:n.hunks,splitLineCount:n.splitLineCount,unifiedLineCount:n.unifiedLineCount,additionLines:n.additionLines,deletionLines:n.deletionLines,type:n.type}}function at(e,t){let n=Math.max(e,1),r=Array.from({length:n},(e,t)=>`${` `.repeat(t+1)}\n`).join(``);return r===t&&(r=Array.from({length:n},(e,t)=>`\u0000${` `.repeat(t)}\n`).join(``)),r}function ot(e){for(let t of e)if(t.trim().length>0)return!1;return!0}function st(e,t){return t.length>0&&t.length<e.deletionLines.length&&ot(t)}function ct(e,t,n){let r=e.deletionLines.join(``),i=at(t.length,r),a=Y({name:e.prevName??e.name,contents:r},{name:e.name,contents:i,lang:e.lang},n);return{hunks:a.hunks,splitLineCount:a.splitLineCount,unifiedLineCount:a.unifiedLineCount,additionLines:t,deletionLines:a.deletionLines,type:a.type}}function lt(e,t){return ct(e,[``],t)}function ut(e,t){if(e.additionLines.length===0)return lt(e,t);if(st(e,e.additionLines))return ct(e,e.additionLines,t);let n=e.additionLines,r=X(e,t);return ft(r,n),r}function dt(e){return e.length>1&&e.at(-1)===``}function ft(e,t){if(!dt(t))return;let n=t.length-e.additionLines.length;if(n<=0)return;let r=e.additionLines.length,i=e.hunks.at(-1);if(i!=null&&i.additionLineIndex+i.additionCount===r){for(let a of i.hunkContent)if(a.type===`change`&&a.additions<a.deletions&&a.additionLineIndex+a.additions===r){e.additionLines=t,a.additions+=n,i.additionCount+=n,i.additionLines+=n,xt(e);return}}}function pt(e,t,n){if(e.isPartial||e.deletionLines.length!==e.additionLines.length)return Z(e,X(e,n));let r=Array.from(t);if(r.length===0)return Z(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type});for(let t of r){let r=e.additionLines[t],i=e.deletionLines[t];if(r==null||i==null||le(r)===le(i))return Z(e,X(e,n))}let i=mt(e,r);if(i.size===0)return Z(e,X(e,n));for(let t of i)if(!gt(e,t,n))return Z(e,X(e,n));return xt(e),Ie(e)?Z(e,X(e,n)):Z(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function Z(e,t){return Object.assign(e,t),t}function mt(e,t){let n=new Set;for(let r of t){let t=ht(e,r);if(t==null)return new Set;n.add(t)}return n}function ht(e,t){for(let[n,r]of e.hunks.entries()){let e=r.additionLineIndex+r.additionCount;if(t>=r.additionLineIndex&&t<e)return n}}function gt(e,t,n){let r=e.hunks[t];if(r==null)return!1;let i=e.deletionLines.slice(r.deletionLineIndex,r.deletionLineIndex+r.deletionCount),a=e.additionLines.slice(r.additionLineIndex,r.additionLineIndex+r.additionCount),o=Y({name:e.prevName??e.name,contents:i.join(``)},{name:e.name,contents:a.join(``),lang:e.lang},{...n,context:0}),s=o.hunks[0];return s==null||o.hunks.length!==1?!1:(vt(r,s),_t(e,t),!0)}function _t(e,t){let n=e.hunks[t];if(n==null)return;if(t!==e.hunks.length-1){n.noEOFCRAdditions=!1,n.noEOFCRDeletions=!1;return}let r=e.additionLines.at(-1),i=e.deletionLines.at(-1);n.noEOFCRAdditions=r!=null&&r!==``&&!r.endsWith(`
2
- `),n.noEOFCRDeletions=i!=null&&i!==``&&!i.endsWith(`
3
- `)}function vt(e,t){let n=e.additionLineIndex,r=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(e=>yt(e,n,r)),e.additionLineIndex=n+t.additionLineIndex,e.additionStart+=t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=r+t.deletionLineIndex,e.deletionStart+=t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,bt(e)}function yt(e,t,n){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+n}}function bt(e){let t=0,n=0;for(let r of e.hunkContent)r.type===`context`?(t+=r.lines,n+=r.lines):(t+=Math.max(r.additions,r.deletions),n+=r.additions+r.deletions);e.splitLineCount=t,e.unifiedLineCount=n}function xt(e){let t=0,n=0,r=0;for(let i of e.hunks)i.collapsedBefore=Math.max(i.additionStart-1-r,0),i.splitLineStart=t+i.collapsedBefore,i.unifiedLineStart=n+i.collapsedBefore,bt(i),t+=i.collapsedBefore+i.splitLineCount,n+=i.collapsedBefore+i.unifiedLineCount,r=i.additionStart+i.additionCount-1;if(e.hunks.length>0){let r=e.hunks[e.hunks.length-1],i=Math.max(e.additionLines.length-(r.additionLineIndex+r.additionCount),0);t+=i,n+=i}e.splitLineCount=t,e.unifiedLineCount=n}function St(e){return e.length>1&&e[e.length-1]===``?e.slice(0,-1):e}function Ct(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;let i=e.length,a=t.length;for(;i>r&&a>r&&e[i-1]===t[a-1];)i--,a--;if(!(r===i&&r===a))return{start:r,prevEnd:i,nextEnd:a}}function wt(e,t,n){let{hunks:r}=e,i=t.nextEnd-t.prevEnd;if(e.editSessionDirty=!0,r.length===0){let t={additionStart:0,additionEnd:e.additionLines.length,deletionStart:0,deletionEnd:e.deletionLines.length};return r.push(jt(e,t,n)),Nt(e,0),{type:`insert`,index:0,previousHunkCount:0}}let a=-1,o=-1;for(let e=0;e<r.length;e++){let n=r[e],i=n.additionLineIndex,s=i+n.additionCount;if(i>t.prevEnd)break;t.start<=s&&(a===-1&&(a=e),o=e)}if(a===-1)return At(e,t,i,n);let s=r[a],c=r[o],l=c.additionLineIndex+c.additionCount,u=Math.min(s.additionLineIndex,t.start),d=Math.max(l,t.prevEnd),f=jt(e,{additionStart:u,additionEnd:d+i,deletionStart:s.deletionLineIndex-(s.additionLineIndex-u),deletionEnd:c.deletionLineIndex+c.deletionCount+(d-l)},n);if(i!==0)for(let e=o+1;e<r.length;e++)Mt(r[e],i);let p=r.length;r.splice(a,o-a+1,f),Nt(e,a);let m=u<s.additionLineIndex||d>l;if(!(a===o&&!m))return{type:`merge`,firstIndex:a,lastIndex:o,previousHunkCount:p}}function Tt(e,t,n){let r=Array.from(new Set(t)).filter(t=>t>=0&&t<e.additionLines.length).sort((e,t)=>e-t);if(r.length===0)return[];let{hunks:i}=e,a=new Set,o=[],s=0,c=-1;for(let e of r){for(;s<i.length&&e>=i[s].additionLineIndex+i[s].additionCount;)s++;let t=i[s];if(t!=null&&e>=t.additionLineIndex){a.add(s);continue}let n=o[o.length-1];c===s&&n!=null?n[1]=e+1:(c=s,o.push([e,e+1]))}for(let t of a){let r=i[t];i[t]=jt(e,{additionStart:r.additionLineIndex,additionEnd:r.additionLineIndex+r.additionCount,deletionStart:r.deletionLineIndex,deletionEnd:r.deletionLineIndex+r.deletionCount},n),_t(e,t),e.editSessionDirty=!0}a.size>0&&xt(e);let l=[];for(let t=o.length-1;t>=0;t--){let[r,i]=o[t],a=wt(e,{start:r,prevEnd:i,nextEnd:i},n);a!=null&&l.push(a)}return l}function Et(e,t){let n=new Map;if(t.type===`merge`){let r=t.lastIndex-t.firstIndex;for(let[i,a]of e)i<=t.firstIndex?n.set(i,a):i>t.lastIndex&&n.set(i-r,a);return n}for(let[r,i]of e)r<t.index?n.set(r,i):r>t.index?n.set(r+1,i):(i.fromStart>0&&n.set(r,{fromStart:i.fromStart,fromEnd:0}),i.fromEnd>0&&n.set(r+1,{fromStart:0,fromEnd:i.fromEnd}));return n}function Dt(e,t,n){let r=[];if(e.isPartial)return r;for(let[i,a]of e.hunks.entries()){let o=I({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:t,hunkIndex:i,collapsedContextThreshold:n});if(o.rangeSize<=n)continue;let s=a.deletionLineIndex,c=s-o.rangeSize;o.fromStart>0&&r.push([c,c+o.fromStart]),o.fromEnd>0&&r.push([s-o.fromEnd,s])}let i=U({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`captureExpansionAnchors`});if(i!=null&&i.fromStart>0&&i.rangeSize>n){let t=e.hunks[e.hunks.length-1],n=t.deletionLineIndex+t.deletionCount;r.push([n,n+i.fromStart])}return r}function Ot(e,t){let n=new Map;if(t.length===0)return n;let r=(e,r,i)=>{if(i<=r)return;let a=0,o=0;for(let[e,n]of t)n<=r||e>=i||(e<=r&&(a=Math.max(a,Math.min(n,i)-r)),n>=i&&(o=Math.max(o,i-Math.max(e,r))));(a>0||o>0)&&n.set(e,{fromStart:a,fromEnd:o})};for(let[t,n]of e.hunks.entries())r(t,n.deletionLineIndex-Math.max(n.collapsedBefore,0),n.deletionLineIndex);let i=e.hunks[e.hunks.length-1];return i!=null&&!e.isPartial&&e.deletionLines.length>0&&r(e.hunks.length,i.deletionLineIndex+i.deletionCount,e.deletionLines.length),n}function kt(e,t){return e.editSessionDirty===!0?(e.editSessionDirty=void 0,Object.assign(e,ut(e,t)),!0):!1}function At(e,t,n,r){let{hunks:i}=e,a=0;for(;a<i.length&&i[a].additionLineIndex<t.start;)a++;let o=a<i.length?i[a].deletionLineIndex-i[a].additionLineIndex:i[a-1].deletionLineIndex+i[a-1].deletionCount-(i[a-1].additionLineIndex+i[a-1].additionCount),{start:s,prevEnd:c,nextEnd:l}=t;(s===c||s===l)&&(s>0?s--:l<e.additionLines.length&&(c++,l++));let u=jt(e,{additionStart:s,additionEnd:l,deletionStart:s+o,deletionEnd:c+o},r);if(n!==0)for(let e=a;e<i.length;e++)Mt(i[e],n);let d=i.length;return i.splice(a,0,u),Nt(e,a),{type:`insert`,index:a,previousHunkCount:d}}function jt(e,t,n){let r=e.deletionLines.slice(t.deletionStart,t.deletionEnd),i=e.additionLines.slice(t.additionStart,t.additionEnd),a=i.length,o=r.length,s=[],c=0,l=0,u=(e,t,n)=>{e>0&&s.push({type:`context`,lines:e,additionLineIndex:t,deletionLineIndex:n})};if(r.join(``)===i.join(``))u(a,t.additionStart,t.deletionStart);else{let o=Y({name:e.prevName??e.name,contents:r.join(``)},{name:e.name,contents:i.join(``),lang:e.lang},{...n,context:0}),d=0,f=0;for(let e of o.hunks){let n=e.additionCount>0?e.additionLineIndex-d:e.deletionLineIndex-f;u(n,t.additionStart+d,t.deletionStart+f),d+=n,f+=n;for(let n of e.hunkContent){let e=yt(n,t.additionStart,t.deletionStart);e.type===`change`&&(e.additions===0&&(e.additionLineIndex=t.additionStart+d),e.deletions===0&&(e.deletionLineIndex=t.deletionStart+f)),s.push(e)}c+=e.additionLines,l+=e.deletionLines,d+=e.additionCount,f+=e.deletionCount}u(a-d,t.additionStart+d,t.deletionStart+f)}let d={collapsedBefore:0,additionStart:t.additionStart+1,additionCount:a,additionLines:c,additionLineIndex:t.additionStart,deletionStart:t.deletionStart+1,deletionCount:o,deletionLines:l,deletionLineIndex:t.deletionStart,hunkContent:s,hunkSpecs:`@@ -${t.deletionStart+1},${o} +${t.additionStart+1},${a} @@`,splitLineStart:0,splitLineCount:0,unifiedLineStart:0,unifiedLineCount:0,noEOFCRAdditions:!1,noEOFCRDeletions:!1};return Se(d,e),bt(d),d}function Mt(e,t){e.additionLineIndex+=t,e.additionStart+=t;for(let n of e.hunkContent)n.additionLineIndex+=t}function Nt(e,t){xt(e),_t(e,t)}async function Pt(e,t=300){let n;try{await Promise.race([e(),new Promise(e=>{n=setTimeout(e,t)})])}finally{n!=null&&clearTimeout(n)}}function Ft({fileDiff:e,metrics:t,disableFileHeader:n,hunkSeparators:r,expandUnchanged:i,expandedHunks:a,collapsedContextThreshold:o,canHydratePartialDiff:s}){let c=H(t,n),l=c,u=i?!0:a,d=e.hunks.length-1;for(let n=0;n<e.hunks.length;n++){let i=e.hunks[n];if(i==null)throw Error(`computeEstimatedDiffHeights: invalid hunk index`);let a=I({isPartial:e.isPartial,rangeSize:i.collapsedBefore,expandedHunks:u,hunkIndex:n,collapsedContextThreshold:o}),f=(a.fromStart+a.fromEnd)*t.lineHeight;if(c+=f,l+=f,a.collapsedLines>0){let e=M({type:r,metrics:t,hunkIndex:n,hunkSpecs:i.hunkSpecs})?.totalHeight??0;c+=e,l+=e}c+=i.splitLineCount*t.lineHeight,l+=i.unifiedLineCount*t.lineHeight;let p=It(i);c+=p.split*t.lineHeight,l+=p.unified*t.lineHeight;let m=n===d?U({fileDiff:e,hunkIndex:n,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:`computeEstimatedDiffHeights`}):void 0;if(m!=null){let e=(m.fromStart+m.fromEnd)*t.lineHeight;if(c+=e,l+=e,m.collapsedLines>0){let e=V({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}else if(n===d&&e.isPartial&&s){let e=V({type:r,metrics:t})?.totalHeight??0;c+=e,l+=e}}if(e.hunks.length>0){let e=Re(t);c+=e,l+=e}return{splitHeight:c,unifiedHeight:l}}function It(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};let t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type===`context`){let e=+(t.lines>0);return{split:e,unified:e}}return Lt(e,t)}function Lt(e,t){let n=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),r=t.deletions>0&&e.noEOFCRDeletions,i=t.additions>0&&e.noEOFCRAdditions;return{split:r||i?1:0,unified:n}}function Rt({oldFile:e,newFile:t},n){if(!(e===void 0&&t===void 0)){if(e===void 0||t===void 0)throw Error(`${n}: Pass null for an intentionally missing oldFile or newFile side`);if(e===null){if(t===null)throw Error(`${n}: You must pass oldFile, newFile, or both`);return{oldFile:e,newFile:t}}return{oldFile:e,newFile:t}}}function zt(e){return{...e,hunks:e.hunks.map(e=>({...e,hunkContent:e.hunkContent.map(e=>({...e}))})),deletionLines:[...e.deletionLines],additionLines:[...e.additionLines]}}function Bt(e){return e===``?[]:e.split(He)}function Vt(e,t,n){let r=e===`clone`?zt(t):t;if(!r.isPartial)throw Error(`hydratePartialDiff: fileDiff must be partial`);switch(r.type){case`change`:case`rename-changed`:return Ht(r,Wt(r,n),Gt(r,n));case`rename-pure`:{let e=Gt(r,n);Kt(r,n);let t=Bt(e.contents);return r.isPartial=!1,r.deletionLines=t,r.additionLines=t,Jt(r,null,e),r}}throw Error(`hydratePartialDiff: ${r.type} diffs cannot be hydrated from loaded files`)}function Ht(e,t,n){let r=Bt(t.contents),i=Bt(n.contents),{hunks:a,splitLineCount:o,unifiedLineCount:s}=Ut(e.hunks,i.length);return e.hunks=a,e.splitLineCount=o,e.unifiedLineCount=s,e.isPartial=!1,e.deletionLines=r,e.additionLines=i,Jt(e,t,n),e}function Ut(e,t){let n=0,r=0,i=0,a=[];for(let t of e){let e=Math.max(t.additionStart-1,0),o=Math.max(t.deletionStart-1,0),s=e,c=o,l=0,u=0,d=0,f=0,p=[];for(let e of t.hunkContent){if(e.type===`context`){p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.lines,c+=e.lines,d+=e.lines,f+=e.lines;continue}p.push({...e,additionLineIndex:s,deletionLineIndex:c}),s+=e.additions,c+=e.deletions,l+=e.additions,u+=e.deletions,d+=Math.max(e.additions,e.deletions),f+=e.additions+e.deletions}let m=Math.max(t.additionStart-1-i,0);a.push({...t,collapsedBefore:m,additionLineIndex:e,deletionLineIndex:o,additionLines:l,deletionLines:u,hunkContent:p,splitLineStart:n+m,unifiedLineStart:r+m,splitLineCount:d,unifiedLineCount:f}),n+=m+d,r+=m+f,i=t.additionStart+t.additionCount-1}if(a.length>0){let e=a[a.length-1],i=Math.max(e.additionStart+e.additionCount-1,0),o=Math.max(t-i,0);n+=o,r+=o}return{hunks:a,splitLineCount:n,unifiedLineCount:r}}function Wt(e,t){if(t.oldFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile`);return t.oldFile}function Gt(e,t){if(t.newFile==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires newFile`);return t.newFile}function Kt(e,t){if(t.oldFile!==null)throw Error(`hydratePartialDiff: ${e.type} diff for ${e.name} requires oldFile to be null`)}function qt(e,t,n){return e.cacheKey==null?Yt(t,n):`${e.cacheKey}:hydrated`}function Jt(e,t,n){let r=qt(e,t,n);if(r==null){delete e.cacheKey;return}e.cacheKey=r}function Yt(e,t){return e!=null&&t!=null?e.cacheKey!=null&&t.cacheKey!=null?`${e.cacheKey}:${t.cacheKey}`:void 0:e?.cacheKey??t?.cacheKey}var Xt=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&=(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,!1)}setup(e,t,n){if(t==null||n==null)for(let r of e.children??[])r instanceof HTMLElement&&(`deletions`in r.dataset?t=r:`additions`in r.dataset&&(n=r));if(n==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener(`scroll`,this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener(`scroll`,this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==n&&(this.codeAdditions?.removeEventListener(`scroll`,this.handleAdditionsScroll),this.codeAdditions=n,n.addEventListener(`scroll`,this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function Zt(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}function Qt(e){return z({tagName:`div`,properties:{"data-content-buffer":``,"data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function $t(e){return z({tagName:`div`,children:[z({tagName:`span`,children:[ce(`No newline at end of file`)]})],properties:{"data-no-newline":``,"data-line-type":e,"data-column-content":``}})}function en(e){return z({tagName:`div`,children:[be({name:e===`both`?`diffs-icon-expand-all`:`diffs-icon-expand`,properties:{"data-icon":``}})],properties:{role:`button`,"data-expand-button":``,"data-expand-both":e===`both`?``:void 0,"data-expand-up":e===`up`?``:void 0,"data-expand-down":e===`down`?``:void 0}})}function Q({type:e,content:t,expandIndex:n,chunked:r=!1,slotName:i,isFirstHunk:a,isLastHunk:o}){let s=0,c=[];if(e===`metadata`&&t!=null&&c.push(z({tagName:`div`,children:[ce(t)],properties:{"data-separator-wrapper":``}})),(e===`line-info`||e===`line-info-basic`)&&t!=null){let e=[];n!=null&&(r?(a||(e.push(en(`up`)),s++),o||(e.push(en(`down`)),s++)):(e.push(en(!a&&!o?`both`:a?`down`:`up`)),s++)),e.push(z({tagName:`div`,children:[z({tagName:`span`,children:[ce(t)],properties:{"data-unmodified-lines":``}})],properties:{"data-separator-content":``}})),r&&n!=null&&e.push(z({tagName:`div`,children:[ce(`Expand all`)],properties:{role:`button`,"data-expand-button":``,"data-expand-all-button":``}})),c.push(z({tagName:`div`,children:e,properties:{"data-separator-wrapper":``,"data-separator-multi-button":s>1?``:void 0}}))}return e===`custom`&&i!=null&&c.push(z({tagName:`slot`,properties:{name:i}})),z({tagName:`div`,children:c,properties:{"data-separator":c.length===0?`simple`:e,"data-expand-index":n,"data-separator-first":a?``:void 0,"data-separator-last":o?``:void 0}})}function tn(e,t){return`hunk-separator-${e}-${t}`}function nn(e){let t=e.at(-1);return t==null?0:Math.max(t.additionStart+t.additionCount,t.deletionStart+t.deletionCount)}var rn=-1,an=class{options;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++rn}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang=`text`;renderCache;editSessionActive=!1;editSessionLines;constructor(e={theme:R},t,n){this.options=e,this.onRenderUpdate=t,this.workerManager=n,n?.isWorkingPool()!==!0&&(this.highlighter=k(e.theme??R)?v():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this),this.endEditSession()}beginEditSession(e){this.editSessionActive=!0,this.editSessionLines=e==null?void 0:St(e.additionLines).slice()}endEditSession(){this.editSessionActive=!1,this.editSessionLines=void 0}get diffCache(){return this.renderCache?.diff??this.diff}clearRenderCache(){let e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.diff.cacheKey!=null&&this.workerManager?.evictDiffFromCache(e.diff.cacheKey)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,n=this.getOptionsWithDefaults().expansionLineCount){let r={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t===`up`||t===`both`)&&(r.fromStart+=n),(t===`down`||t===`both`)&&(r.fromEnd+=n),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,r)}getExpandedHunk(e){return this.expandedHunks.get(e)??_e}getExpandedHunksMap(){return this.expandedHunks}setExpandedHunksMap(e){this.expandedHunks=e}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(let t of e){let e=(()=>{switch(t.side){case`deletions`:return this.deletionAnnotations;case`additions`:return this.additionAnnotations}})(),n=e[t.lineNumber]??[];e[t.lineNumber]=n,n.push(t)}}updateRenderCache(e,t,n=!1){if(this.renderCache==null)return!1;let{result:r,diff:i}=this.renderCache;if(r==null)return!1;if(i.isPartial)throw Error(`Could not update render cache for partial diff`);let a=r.code.additionLines,o=[];for(let[t,n]of e){let e=a[t]?.properties??{},r=n.map(e=>e[2]).join(``),s=t<i.additionLines.length,c=s?i.additionLines[t]??``:``,l=le(c);s&&(i.additionLines[t]=h(c,r),l!==r&&o.push(t)),a[t]={type:`element`,tagName:`div`,properties:{"data-line":e[`data-line`]??t+1,"data-line-index":e[`data-line-index`]??t,"data-line-type":e[`data-line-type`]??`context`},children:n.map(([e,t,n])=>e===0&&t===``?n===``?{type:`element`,tagName:`br`,properties:{},children:[]}:{type:`text`,value:n}:{type:`element`,tagName:`span`,properties:{"data-char":e,style:`color:${t};`},children:[{type:`text`,value:n}]})}}let s=!1;if(o.length>0)if(this.editSessionActive&&!i.isPartial){if(!n){let e=Tt(i,o,this.options.parseDiffOptions);this.applyExpansionRemaps(e),s=e.length>0,this.editSessionLines=St(i.additionLines).slice()}}else Object.assign(i,pt(i,o,this.options.parseDiffOptions));return r.baseThemeType=t,this.renderCache.isDirty=!0,s}applyExpansionRemaps(e){for(let t of e)this.expandedHunks=Et(this.expandedHunks,t)}applyDocumentChange(e){if(this.renderCache==null)return;let{diff:t,result:n}=this.renderCache;if(n==null)return;t.additionLines=hn(e,t.additionLines);let r=t.additionLines.length,i=n.code.additionLines,a=i.length;r<a&&(i.length=r);for(let t=a;t<r;t++)i[t]??=mn(t,e);t.isPartial||(t.additionLines.length<=1&&t.additionLines.join(``)===``?(Object.assign(t,lt(t,this.options.parseDiffOptions)),i[0]=mn(0,e),this.markEditSessionPass(t)):this.editSessionActive?this.applySessionDocumentChange(t):Object.assign(t,ut(t,this.options.parseDiffOptions))),this.renderCache.isDirty=!0}applySessionDocumentChange(e){let{parseDiffOptions:t}=this.options,n=e.additionLines;if(st(e,n)){Object.assign(e,ct(e,n,t)),this.markEditSessionPass(e);return}let r=this.editSessionLines,i=St(n);if(r==null){Object.assign(e,ut(e,t)),this.markEditSessionPass(e);return}e.additionLines=i;let a=Ct(r,i);if(a!=null){let n=wt(e,a,t);n!=null&&this.applyExpansionRemaps([n])}ft(e,n),this.editSessionLines=i.slice()}markEditSessionPass(e){this.editSessionActive&&(e.editSessionDirty=!0,this.editSessionLines=St(e.additionLines).slice())}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){let n=t===`change`?e===`deletions`?`change-deletion`:`change-addition`:t;return{gutterLineType:n,contentProperties:{"data-line-type":n}}}createAnnotationElement=e=>_(e);getOptionsWithDefaults(){let{diffIndicators:e=`bars`,diffStyle:t=`split`,disableBackground:n=!1,disableFileHeader:r=!1,disableLineNumbers:i=!1,disableVirtualizationBuffers:a=!1,collapsed:o=!1,expandUnchanged:s=!1,collapsedContextThreshold:c=1,expansionLineCount:l=100,hunkSeparators:u=`line-info`,lineDiffType:d=`word-alt`,maxLineDiffLength:f=1e3,overflow:p=`scroll`,stickyHeader:m=!1,theme:h=R,headerRenderMode:g=`default`,tokenizeMaxLineLength:_=1e3,tokenizeMaxLength:v=ye,useTokenTransformer:y=!1,useCSSClasses:b=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:n,disableFileHeader:r,disableLineNumbers:i,disableVirtualizationBuffers:a,collapsed:o,expandUnchanged:s,collapsedContextThreshold:c,expansionLineCount:l,hunkSeparators:u,lineDiffType:d,maxLineDiffLength:f,overflow:p,stickyHeader:m,theme:this.workerManager?.getDiffRenderOptions().theme??h,headerRenderMode:g,tokenizeMaxLineLength:_,tokenizeMaxLength:v,useTokenTransformer:y,useCSSClasses:b}}async initializeHighlighter(){return this.highlighter=await g(P(this.computedLang,this.options)),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;let{options:t}=this.getRenderOptions(e),n=vn(e,this.getTokenizeMaxLength()),r=this.workerManager?.getDiffResultCache(e);r!=null&&!B(t,r.options)&&(r=void 0),this.renderCache??={diff:e,highlighted:!n&&!me(e),options:t,result:n?void 0:r?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!n&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter??(this.computedLang=e.lang??te(e.name),this.initializeHighlighter())}getRenderOptions(e){let t=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getDiffRenderOptions();let{theme:e,tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}=this.getOptionsWithDefaults();return{theme:e,useTokenTransformer:Ue(this.options),tokenizeMaxLineLength:t,lineDiffType:n,maxLineDiffLength:r}})();this.getOptionsWithDefaults();let{renderCache:n}=this;return n?.result==null||!W(e,n.diff)||!B(t,n.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}renderDiff(e=this.renderCache?.diff,t=Me){if(e==null)return;let{expandUnchanged:n,collapsedContextThreshold:r}=this.getOptionsWithDefaults(),{options:i,forceHighlight:a}=this.getRenderOptions(e),o=this.getMatchingWorkerResultCache(e,i);o!=null&&!this.hasHighlightedRenderCache(e,i)&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...o},a=!1),this.renderCache??={diff:e,highlighted:!1,options:i,result:void 0,renderRange:void 0};let s=e.additionLines.length>0||e.deletionLines.length>0,c=!s||me(e)||vn(e,this.getTokenizeMaxLength()),l=!W(e,this.renderCache.diff),u=!d(this.renderCache.renderRange,t);if(this.workerManager?.isWorkingPool()===!0)(c||this.renderCache.result==null||!this.renderCache.highlighted&&(l||u))&&(this.renderCache.diff=e,this.renderCache.options=i,this.renderCache.highlighted=!1,(this.renderCache.result==null||l||u||a)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,Zt(t)||n?!0:this.expandedHunks,r)),this.renderCache.renderRange=t),!c&&s&&(!this.renderCache.highlighted||a)&&this.workerManager.highlightDiffAST(this,e);else{this.computedLang=e.lang??te(e.name);let t=this.highlighter!=null&&k(i.theme),n=this.highlighter!=null&&Ee(this.computedLang),r=!c&&n;if(this.highlighter!=null&&t&&(a||c||!this.renderCache.highlighted&&r||this.renderCache.result==null)){let{result:t,options:i}=this.renderDiffWithHighlighter(e,this.highlighter,c||!n);this.renderCache={diff:e,options:i,highlighted:r,result:t,renderRange:void 0}}(!t||!c&&!n)&&this.asyncHighlight(e).then(({result:t,options:n})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(e,t,n,!c)})}return this.renderCache.result==null?void 0:this.processDiffResult(this.renderCache.diff,t,this.renderCache.result)}async asyncRender(e,t=Me){let{result:n}=await this.asyncHighlight(e);return this.processDiffResult(e,t,n)}createPreElement(e,t,n){let{diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o}=this.getOptionsWithDefaults();return p({type:`diff`,diffIndicators:r,disableBackground:i,disableLineNumbers:a,overflow:o,split:e,totalLines:t,customProperties:n})}async asyncHighlight(e){let t=vn(e,this.getTokenizeMaxLength());this.computedLang=t?`text`:e.lang??te(e.name);let n=this.highlighter!=null&&k(this.options.theme??R),r=t||this.highlighter!=null&&Ee(this.computedLang);return(this.highlighter==null||!n||!r)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,n=!1){let{options:r}=this.getRenderOptions(e),{collapsedContextThreshold:i}=this.getOptionsWithDefaults();return{result:C(e,t,r,{forcePlainText:n,expandedHunks:n?!0:void 0,collapsedContextThreshold:i}),options:r}}onHighlightSuccess(e,t,n,r=!0){if(this.renderCache==null)return;let i=!this.renderCache.highlighted||!B(this.renderCache.options,n)||!W(this.renderCache.diff,e);this.renderCache={diff:e,options:n,highlighted:r,result:t,renderRange:void 0},i&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){let n=this.workerManager?.getDiffResultCache(e);if(!(n==null||!B(t,n.options)))return n}hasHighlightedRenderCache(e,t){let{renderCache:n}=this;return n?.result!=null&&n.highlighted&&W(e,n.diff)&&B(t,n.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:n,themeStyles:r,baseThemeType:i}){let{diffStyle:a,disableFileHeader:o,expandUnchanged:s,expansionLineCount:c,collapsedContextThreshold:l,hunkSeparators:u}=this.getOptionsWithDefaults(),d=this.renderCache?.isDirty??!1;this.diff=e;let f=a===`unified`,p=yn(e,this.options.loadDiffFiles!=null),m=!e.isPartial||p,h=[],g=[],_=[],v=[],{additionLines:y,deletionLines:b}=n,x={rowCount:0,hunkSeparators:u,additionsContentAST:h,deletionsContentAST:g,unifiedContentAST:_,unifiedGutterAST:Ae(),deletionsGutterAST:Ae(),additionsGutterAST:Ae(),expansionLineCount:c,hunkData:v,incrementRowCount(e=1){x.rowCount+=e},pushToGutter(e,t){switch(e){case`unified`:x.unifiedGutterAST.children.push(t);break;case`deletions`:x.deletionsGutterAST.children.push(t);break;case`additions`:x.additionsGutterAST.children.push(t);break}}},S=ge({fileDiff:e,errorPrefix:`DiffHunksRenderer.processDiffResult`}),C={size:0,side:void 0,increment(){this.size+=1},flush(){if(a!==`unified`){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side===`additions`?(x.pushToGutter(`additions`,L(void 0,`buffer`,this.size)),h?.push(Qt(this.size))):(x.pushToGutter(`deletions`,L(void 0,`buffer`,this.size)),g?.push(Qt(this.size))),this.size=0,this.side=void 0}}},w=(e,t,n,r,i)=>{x.pushToGutter(e,Ne(t,n,r,i))};function T(e){C.flush(),a===`unified`?fn(`unified`,e,x):(fn(`deletions`,e,x),fn(`additions`,e,x))}this.pushFileLevelAnnotations(e,a,t,x),F({diff:e,diffStyle:a,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:s?!0:this.expandedHunks,collapsedContextThreshold:l,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,additionLine:o,deletionLine:s,type:c})=>{let l=s==null?o.splitLineIndex:s.splitLineIndex,f=o==null?s.unifiedLineIndex:o.unifiedLineIndex;a===`split`&&c!==`change`&&C.flush(),r>0&&T({hunkIndex:t,collapsedLines:r,rangeSize:Math.max(n?.collapsedBefore??0,0),hunkSpecs:n?.hunkSpecs,isFirstHunk:t===0,isLastHunk:!1,isExpandable:m});let h=a===`unified`?f:l,g={type:c,hunkIndex:t,lineIndex:h,unifiedLineIndex:f,splitLineIndex:l,deletionLine:s,additionLine:o};if(a===`unified`){let n=this.getUnifiedInjectedRowsForLine?.(g);n?.before!=null&&ln(n.before,x);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex];if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let a=c===`change`?o==null?`change-deletion`:`change-addition`:c,u=this.getUnifiedLineDecoration({type:c,lineType:a,additionLineIndex:o?.lineIndex,deletionLineIndex:s?.lineIndex});w(`unified`,u.gutterLineType,o==null?s.lineNumber:o.lineNumber,`${f},${l}`,u.gutterProperties),i==null?r!=null&&(r=pn(r,u.contentProperties,d&&s!=null?{"data-line":s.lineNumber,"data-line-index":`${f},${l}`}:void 0)):i=pn(i,u.contentProperties,d&&o!=null?{"data-line":o.lineNumber,"data-line-index":`${f},${l}`}:void 0),dn({diffStyle:`unified`,type:c,deletionLine:r,additionLine:i,unifiedSpan:this.getAnnotations(`unified`,s?.lineNumber,o?.lineNumber,t,h),createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&ln(n.after,x)}else{let n=this.getSplitInjectedRowsForLine?.(g);n?.before!=null&&un(n.before,x,C);let r=s==null?void 0:b[s.lineIndex],i=o==null?void 0:y[o.lineIndex],a=this.getSplitLineDecoration({side:`deletions`,type:c,lineIndex:s?.lineIndex}),u=this.getSplitLineDecoration({side:`additions`,type:c,lineIndex:o?.lineIndex});if(r==null&&i==null){let t=`DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong`;throw console.error(t,{file:e.name}),Error(t)}let f=(()=>{if(c===`change`){if(i==null)return`additions`;if(r==null)return`deletions`}})();f==null?c===`change`&&C.flush():(C.side!=null&&C.side!==f&&C.flush(),C.side=f,C.increment());let p=this.getAnnotations(`split`,s?.lineNumber,o?.lineNumber,t,h);if(p!=null&&C.size>0&&C.flush(),s!=null){let e=pn(r,a.contentProperties,d?{"data-line":s.lineNumber,"data-line-index":`${s.unifiedLineIndex},${l}`}:void 0);w(`deletions`,a.gutterLineType,s.lineNumber,`${s.unifiedLineIndex},${l}`,a.gutterProperties),e!=null&&(r=e)}if(o!=null){let e=pn(i,u.contentProperties,d?{"data-line":o.lineNumber,"data-line-index":`${o.unifiedLineIndex},${l}`}:void 0);w(`additions`,u.gutterLineType,o.lineNumber,`${o.unifiedLineIndex},${l}`,u.gutterProperties),e!=null&&(i=e)}dn({diffStyle:`split`,type:c,additionLine:i,deletionLine:r,...p,createAnnotationElement:e=>this.createAnnotationElement(e),context:x}),n?.after!=null&&un(n.after,x,C)}let _=a===`split`&&n!=null&&l===n.splitLineStart+n.splitLineCount-1,v=t===e.hunks.length-1&&n!=null&&(a===`split`?l===n.splitLineStart+n.splitLineCount-1:f===n.unifiedLineStart+n.unifiedLineCount-1),E=_?n.noEOFCRDeletions:!1,D=_?n.noEOFCRAdditions:!1,O=(s?.noEOFCR??!1)||E,k=(o?.noEOFCR??!1)||D;if(k||O){if(a===`split`&&C.flush(),O){let e=c===`context`||c===`context-expanded`?c:`change-deletion`;a===`unified`?(x.unifiedContentAST.push($t(e)),x.pushToGutter(`unified`,L(e,`metadata`,1))):(x.deletionsContentAST.push($t(e)),x.pushToGutter(`deletions`,L(e,`metadata`,1)),k||(x.pushToGutter(`additions`,L(void 0,`buffer`,1)),x.additionsContentAST.push(Qt(1))))}if(k){let e=c===`context`||c===`context-expanded`?c:`change-addition`;a===`unified`?(x.unifiedContentAST.push($t(e)),x.pushToGutter(`unified`,L(e,`metadata`,1))):(x.additionsContentAST.push($t(e)),x.pushToGutter(`additions`,L(e,`metadata`,1)),O||(x.pushToGutter(`deletions`,L(void 0,`buffer`,1)),x.deletionsContentAST.push(Qt(1))))}x.incrementRowCount(1)}u!==`simple`&&u!==`metadata`&&(i>0||v&&p)&&T({hunkIndex:c===`context-expanded`?t:t+1,collapsedLines:v&&p?`unknown`:i,rangeSize:S,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:m}),x.incrementRowCount(1)}}),a===`split`&&C.flush();let E=Math.max(nn(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),D=t.bufferBefore>0||t.bufferAfter>0,O=!f&&e.type!==`deleted`,k=!f&&e.type!==`new`,A=x.rowCount>0||D;h=O&&A?h:void 0,g=k&&A?g:void 0,_=f&&A?_:void 0;let j=this.createPreElement(g!=null&&h!=null,E);return{unifiedGutterAST:f&&A?x.unifiedGutterAST.children:void 0,unifiedContentAST:_,deletionsGutterAST:k&&A?x.deletionsGutterAST.children:void 0,deletionsContentAST:g,additionsGutterAST:O&&A?x.additionsGutterAST.children:void 0,additionsContentAST:h,hunkData:v,preNode:j,themeStyles:r,baseThemeType:i,headerElement:o?void 0:this.renderHeader(this.diff),totalLines:E,rowCount:x.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:``}}renderCodeAST(e,t){let n=e===`unified`?t.unifiedGutterAST:e===`deletions`?t.deletionsGutterAST:t.additionsGutterAST,r=e===`unified`?t.unifiedContentAST:e===`deletions`?t.deletionsContentAST:t.additionsContentAST;if(n==null||r==null)return;let i=Ae(n);return i.properties.style=`grid-row: span ${t.rowCount}`,[i,ne(r,t.rowCount)]}renderFullAST(e,t=[]){let n=this.getOptionsWithDefaults().hunkSeparators===`line-info`,r=this.renderCodeAST(`unified`,e);if(r!=null)return t.push(z({tagName:`code`,children:r,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-unified":``}})),{...e.preNode,children:t};let i=this.renderCodeAST(`deletions`,e);i!=null&&t.push(z({tagName:`code`,children:i,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-deletions":``}}));let a=this.renderCodeAST(`additions`,e);return a!=null&&t.push(z({tagName:`code`,children:a,properties:{"data-code":``,"data-container-size":n?``:void 0,"data-additions":``}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return G(this.renderFullAST(e,t))}renderPartialHTML(e,t){return G(t==null?e:z({tagName:`code`,children:e,properties:{"data-code":``,"data-container-size":this.getOptionsWithDefaults().hunkSeparators===`line-info`?``:void 0,[`data-${t}`]:``}}))}pushFileLevelAnnotations(e,t,n,r){if(!T(n))return;let i=e.type===`new`?[]:on(y(this.deletionAnnotations)),a=e.type===`deleted`?[]:on(y(this.additionAnnotations));if(i.length===0&&a.length===0)return;let{createAnnotationElement:o}=this;if(t===`unified`){dn({diffStyle:t,type:`context`,unifiedSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i.concat(a)},createAnnotationElement:o,context:r});return}dn({diffStyle:t,type:`context`,deletionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:i},additionSpan:{type:`annotation`,hunkIndex:-1,lineIndex:-1,annotations:a},createAnnotationElement:o,context:r})}getAnnotations(e,t,n,r,i){let a={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(t!=null)for(let e of this.deletionAnnotations[t]??[])a.annotations.push(O(e));let o={type:`annotation`,hunkIndex:r,lineIndex:i,annotations:[]};if(n!=null)for(let t of this.additionAnnotations[n]??[])(e===`unified`?a:o).annotations.push(O(t));if(e===`unified`)return a.annotations.length>0?a:void 0;if(!(o.annotations.length===0&&a.annotations.length===0))return{deletionSpan:a,additionSpan:o}}renderHeader(e){let{headerRenderMode:t,stickyHeader:n}=this.getOptionsWithDefaults();return Ve({fileOrDiff:e,mode:t,stickyHeader:n})}};function on(e){return e?.map(e=>O(e))??[]}var sn=new Intl.PluralRules(`en-US`);function cn(e){return`${e} unmodified line${sn.select(e)===`one`?``:`s`}`}function ln(e,t){for(let n of e)t.unifiedContentAST.push(n.content),t.pushToGutter(`unified`,n.gutter),t.incrementRowCount(1)}function un(e,t,n){for(let{deletion:r,addition:i}of e){if(r==null&&i==null)continue;let e=r!=null&&i!=null?void 0:r==null?`deletions`:`additions`;(e==null||n.side!==e)&&n.flush(),r!=null&&(t.deletionsContentAST.push(r.content),t.pushToGutter(`deletions`,r.gutter)),i!=null&&(t.additionsContentAST.push(i.content),t.pushToGutter(`additions`,i.gutter)),e!=null&&(n.side=e,n.increment()),t.incrementRowCount(1)}}function dn({diffStyle:e,type:t,deletionLine:n,additionLine:r,unifiedSpan:i,deletionSpan:a,additionSpan:o,createAnnotationElement:s,context:c}){let l=!1;if(e===`unified`){if(r==null?n!=null&&c.unifiedContentAST.push(n):c.unifiedContentAST.push(r),i!=null){let e=t===`change`?n==null?`change-addition`:`change-deletion`:t;c.unifiedContentAST.push(s(i)),c.pushToGutter(`unified`,L(e,`annotation`,1)),l=!0}}else if(e===`split`){if(n!=null&&c.deletionsContentAST.push(n),r!=null&&c.additionsContentAST.push(r),a!=null){let e=t===`change`?n==null?`context`:`change-deletion`:t;c.deletionsContentAST.push(s(a)),c.pushToGutter(`deletions`,L(e,`annotation`,1)),l=!0}if(o!=null){let e=t===`change`?r==null?`context`:`change-addition`:t;c.additionsContentAST.push(s(o)),c.pushToGutter(`additions`,L(e,`annotation`,1)),l=!0}}l&&c.incrementRowCount(1)}function fn(e,{hunkIndex:t,collapsedLines:n,rangeSize:r,hunkSpecs:i,isFirstHunk:a,isLastHunk:o,isExpandable:s},c){if(typeof n==`number`&&n<=0)return;let l=e===`unified`?c.unifiedContentAST:e===`deletions`?c.deletionsContentAST:c.additionsContentAST;if(c.hunkSeparators===`metadata`){i!=null&&(c.pushToGutter(e,Q({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),l.push(Q({type:`metadata`,content:i,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1));return}if(c.hunkSeparators===`simple`){t>0&&(c.pushToGutter(e,Q({type:`simple`,isFirstHunk:a,isLastHunk:!1})),l.push(Q({type:`simple`,isFirstHunk:a,isLastHunk:!1})),e!==`additions`&&c.incrementRowCount(1));return}let u=tn(e,t),d=r>c.expansionLineCount,f=s?t:void 0,p=typeof n==`number`?cn(n):`More unchanged context may be available`;c.pushToGutter(e,Q({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),l.push(Q({type:c.hunkSeparators,content:p,expandIndex:f,chunked:d,slotName:u,isFirstHunk:a,isLastHunk:o})),e!==`additions`&&c.incrementRowCount(1),c.hunkData.push({slotName:u,hunkIndex:t,lines:typeof n==`number`?n:0,lineCountKnown:typeof n==`number`,type:e,expandable:s?{up:!a,down:!o,chunked:d}:void 0})}function pn(e,t,n){return e==null||e.type!==`element`||t==null&&n==null?e:{...e,properties:{...e.properties,...t,...n}}}function mn(e,t){return{type:`element`,tagName:`div`,properties:{"data-line":e+1,"data-line-index":`${e},${e}`,"data-line-type":`context`},children:[{type:`element`,tagName:`span`,properties:{"data-char":0},children:[{type:`text`,value:t.getLineText(e)}]}]}}function hn(e,t){let n=[],r=_n(t);for(let t=0;t<e.lineCount;t++){let i=e.getLineText(t,!0);n.push(t<e.lineCount-1&&!gn(i)?i+r:i)}return n}function gn(e){return e.endsWith(`
4
- `)||e.endsWith(`\r`)}function _n(e){for(let t of e){if(t.endsWith(`\r
5
- `))return`\r
6
- `;if(t.endsWith(`
7
- `))return`
8
- `;if(t.endsWith(`\r`))return`\r`}return`
9
- `}function vn(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function yn(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function bn(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function xn(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.lineCountKnown===t.lineCountKnown&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function Sn(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:e?.useTokenTransformer,tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators==`function`?`custom`:e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,loadDiffFiles:e?.loadDiffFiles,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader==null?`default`:`custom`}}function Cn(e){return e.isPartial&&(e.type===`change`||e.type===`rename-changed`||e.type===`rename-pure`)}var wn=-1,Tn=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++wn}`;type=`file-diff`;fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;renderRange;pendingFiles;appliedPreAttributes;lastRenderedHeaderHTML;cachedHeaderHTML;lastRowCount;mounted=!1;enabled=!0;editor;refreshViewTimeout;deferSetSelection;constructor(e={theme:R},t,n=!1){this.options=e,this.workerManager=t,this.isContainerManaged=n,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new we,this.scrollSyncManager=new Xt,this.interactionManager=new E(`diff`,D(e,typeof e.hunkSeparators==`function`||(e.hunkSeparators??`line-info`)===`line-info`||e.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getHunksRendererOptions(e){return Sn(e)}createHunksRenderer(e){return new an(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t=`additions`)=>{let n=this.fileDiffCache;if(n==null)return;let r=n.hunks.at(-1),i,a;hunkIterator:for(let o of n.hunks){let n=t===`deletions`?o.deletionStart:o.additionStart,s=t===`deletions`?o.deletionCount:o.additionCount,c=o.splitLineStart,l=o.unifiedLineStart;if(e<n){let t=n-e;i=Math.max(l-t,0),a=Math.max(c-t,0);break hunkIterator}if(e>=n+s){if(o===r){let t=e-(n+s);i=l+o.unifiedLineCount+t,a=c+o.splitLineCount+t;break hunkIterator}continue}for(let r of o.hunkContent)if(r.type===`context`)if(e<n+r.lines){let t=e-n;a=c+t,i=l+t;break hunkIterator}else n+=r.lines,c+=r.lines,l+=r.lines;else{let o=t===`deletions`?r.deletions:r.additions;if(e<n+o){let o=e-n;i=l+(t===`additions`?r.deletions:0)+o,a=c+o;break hunkIterator}else n+=o,c+=Math.max(r.deletions,r.additions),l+=r.deletions+r.additions}break hunkIterator}if(!(i==null||a==null))return[i,a]};setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(D(this.options,typeof this.options.hunkSeparators==`function`||(this.options.hunkSeparators??`line-info`)===`line-info`||this.options.hunkSeparators===`line-info-basic`?this.handleExpandHunk:void 0,this.getLineIndex))}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;let 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&&!Te(this.appliedThemeCSS.theme,this.options.theme??R)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,n){return!(e||t||n||typeof this.options.hunkSeparators==`function`)}setSelectedLines(e,t){this.refreshViewTimeout==null?this.interactionManager.setSelection(e,t):this.deferSetSelection=[e,t]}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}let{diffStyle:e=`split`,overflow:t=`scroll`}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,{disableAnnotations:t===`wrap`,columnVariables:this.shouldApplyColumnVariables(t)?`apply`:`measure`}),t===`scroll`&&e===`split`?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}shouldApplyColumnVariables(e){return typeof this.options.hunkSeparators==`function`?!0:e===`scroll`&&(this.lineAnnotations.length>0||this.pre?.hasAttribute(`data-has-merge-conflict`)===!0)}cleanUp(e=!1){ie(this.handleEditSessionRender),this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.pendingFiles=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder?.remove(),this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper?.remove(),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.enabled=!1,this.editor?.cleanUp(e),this.editor=void 0,this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0)}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate({fileContainer:e,prerenderedHTML:t,preventEmit:n=!1,lineAnnotations:r,fileDiff:i,...a}){if(!this.enabled)throw Error(`FileDiff.hydrate: attempting to call hydrate after cleaned up`);if(this.fileContainer!=null)throw Error(`FileDiff.hydrate: hydrate can only be called before the instance has rendered or hydrated`);let o=Rt(a,`FileDiff.hydrate`),s=o?.oldFile,c=o?.newFile;this.hydrateElements(e,t),kn(this.pre,Dn({fileDiff:i,oldFile:s,newFile:c}),this.options.collapsed)||An(this.headerElement,On({fileDiff:i,oldFile:s,newFile:c}),this.options.disableFileHeader)?this.render({...a,fileContainer:e,lineAnnotations:r,fileDiff:i,preventEmit:!0}):this.hydrationSetup({fileDiff:i,lineAnnotations:r,...o}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),pe(e,t);for(let t of e.shadowRoot?.children??[]){if(t instanceof SVGElement){this.spriteSVG=t;continue}if(t instanceof HTMLElement){if(t instanceof HTMLPreElement){this.pre=t;for(let e of t.children)!(e instanceof HTMLElement)||e.tagName.toLowerCase()!==`code`||(`deletions`in e.dataset&&(this.codeDeletions=e),`additions`in e.dataset&&(this.codeAdditions=e),`unified`in e.dataset&&(this.codeUnified=e));continue}if(`diffsHeader`in t.dataset){this.headerElement=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-theme-css`)){this.themeCSSStyle=t;continue}if(t instanceof HTMLStyleElement&&t.hasAttribute(`data-unsafe-css`)){this.unsafeCSSStyle=t,this.appliedUnsafeCSS=t.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute(`data-dehydrated`)),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:n,lineAnnotations:r}){this.lineAnnotations=r??this.lineAnnotations,this.additionFile=n,this.deletionFile=t,this.fileDiff=e??(t!==void 0&&n!==void 0?Y(t,n,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,n)=>{this.expandHunk(e,t,n)};expandHunk=(e,t,n)=>{this.hunksRenderer.expandHunk(e,t,n),this.loadFilesIfNecessary(),this.rerender()};loadFilesIfNecessary(){let{fileDiff:e,options:{loadDiffFiles:t}}=this;e==null||t==null||!Cn(e)||this.pendingFiles?.fileDiff===e||(this.pendingFiles={fileDiff:e,promise:this.loadFilesForDiff(e,t)})}async loadFilesForDiff(e,t){try{let n=await t(e);if(!this.enabled||this.fileDiff!==e)return;await this.handleFilesLoaded(e,n)}catch(e){if(this.options.disableErrorHandling===!0)throw e;console.error(e)}finally{this.pendingFiles?.fileDiff===e&&(this.pendingFiles=void 0)}}async handleFilesLoaded(e,t){this.fileDiff!==e||!e.isPartial||(Vt(`merge`,e,t),this.setHydratedState(t),await Pt(()=>this.primeHighlightCache(e)),!(!this.enabled||this.fileDiff!==e)&&this.rerender())}setHydratedState(e){this.deletionFile=e.oldFile,this.additionFile=e.newFile,this.workerManager?.cleanUpTasks(this.hunksRenderer),this.hunksRenderer.clearRenderCache()}render({fileDiff:e,deferManagers:t=!1,forceRender:n=!1,preventEmit:r=!1,lineAnnotations:i,fileContainer:a,containerWrapper:o,renderRange:s,...c}){let l=Rt(c,`FileDiff.render`),u=l?.oldFile,f=l?.newFile;if(!this.enabled)throw Error(`FileDiff.render: attempting to call render after cleaned up`);e!=null&&e.cacheKey===void 0&&(e.cacheKey=e.prevName==null?e.name:e.prevName+`:`+e.name),this.editor?.__postponeBgTokenizeToNextFrame();let{collapsed:p=!1,themeType:m=`system`,expandUnchanged:h=!1}=this.options,g=p?void 0:s,_=this.hasThemeChanged(),v=l!=null,y=v&&(!En(u,this.deletionFile)||!En(f,this.additionFile)),b=e!=null&&e!==this.fileDiff,x=i!=null&&(i.length>0||this.lineAnnotations.length>0)?i!==this.lineAnnotations:!1;if(!p&&d(g,this.renderRange)&&!n&&!x&&!_&&(e!=null&&e===this.fileDiff||e==null&&!y))return this.applyCachedThemeState(m);let S;e==null&&v&&(y||this.fileDiff==null)&&(S=Y(l.oldFile,l.newFile,this.options.parseDiffOptions));let{renderRange:C}=this;if(this.renderRange=g,this.deletionFile=u,this.additionFile=f,e==null?S!=null&&(b=!0,this.fileDiff=S):this.fileDiff=e,b&&(this.cachedHeaderHTML=void 0),i!=null&&this.setLineAnnotations(i),this.fileDiff==null)return!1;this.fileDiff.editSessionDirty===!0&&this.shouldSelfHealEditSession()&&kt(this.fileDiff,this.options.parseDiffOptions),h&&this.loadFilesIfNecessary(),this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);let{disableErrorHandling:w=!1,disableFileHeader:T=!1}=this.options;if(T&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,o),this.applyCachedThemeState(m),p){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{let e=this.hunksRenderer.renderDiff(this.fileDiff,fe);e!=null&&this.applyThemeState(a,e.themeStyles,m,e.baseThemeType),e?.headerElement!=null&&this.applyHeaderToDOM(e.headerElement,a),this.renderSeparators([]),this.injectUnsafeCSS()}catch(e){if(w)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}try{let e=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(n,x,y||b||_)&&this.applyPartialRender({previousRenderRange:C,renderRange:g}))){let t=this.hunksRenderer.renderDiff(this.fileDiff,g);if(t==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(a,t.themeStyles,m,t.baseThemeType),t.headerElement!=null&&this.applyHeaderToDOM(t.headerElement,a),t.additionsContentAST!=null||t.deletionsContentAST!=null||t.unifiedContentAST!=null?this.applyHunksToDOM(e,t):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(t.hunkData)}this.applyBuffers(e,g),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,t||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(e){if(w)throw e;console.error(e),e instanceof Error&&this.applyErrorToDOM(e,a)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){let{fileContainer:t,options:{onPostRender:n}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,`unmount`);return}if(t==null)return;let r=this.mounted?`update`:`mount`;this.mounted=!0,n?.(t,this,r)}get fileDiffCache(){return this.hunksRenderer.diffCache??this.fileDiff}syncRenderViewToEditor(){let e=this.editor,t=this.fileContainer,n=this.fileDiffCache,r=this.lineAnnotations,i=this.computeEditorRenderRange(this.renderRange);e!=null&&t!=null&&n!=null&&!n.isPartial&&this.hunksRenderer.initializeHighlighter().then(a=>{!this.enabled||this.editor!==e||this.fileContainer!==t||this.fileDiffCache!==n||e.__syncRenderView(a,t,n,r,i)})}computeEditorRenderRange(e){let t=this.fileDiffCache;if(e==null||t==null||Zt(e))return e;let{diffStyle:n=`split`,expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a,o;return F({diff:t,diffStyle:n,startingLine:e.startingLine,totalLines:e.totalLines,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({additionLine:e})=>{e!=null&&(a??=e.lineNumber,o=e.lineNumber)}}),a==null||o==null?{...e,startingLine:0,totalLines:0}:{...e,startingLine:a-1,totalLines:o-a+1}}attachEditor(e){return this.editor?.cleanUp(),this.editor=e,this.interactionManager.setEditorAttached(!0),this.type===`file-diff`&&this.hunksRenderer.beginEditSession(this.fileDiffCache),this.fileDiff?.isPartial===!0&&this.loadFilesIfNecessary(),this.syncRenderViewToEditor(),e=>{this.editor=void 0,this.interactionManager.setEditorAttached(!1),e!==!0&&this.finishEditSession()}}finishEditSession(){this.hunksRenderer.endEditSession(),this.completeEditSession()}completeEditSession(){let e=this.fileDiffCache;if(e==null||e.editSessionDirty!==!0)return!1;let{collapsedContextThreshold:t=1}=this.options,n=Dt(e,this.hunksRenderer.getExpandedHunksMap(),t);return kt(e,this.options.parseDiffOptions),this.hunksRenderer.setExpandedHunksMap(Ot(e,n)),this.escalateEditSessionRender(),!0}applyDocumentChange(e,t){this.hunksRenderer.applyDocumentChange(e);let n=this.hunksRenderer.diffCache;if(n!=null){let e=this.fileDiff?.cacheKey;e!=null&&n.cacheKey==null&&(n.cacheKey=e),this.fileDiff=n}t!==void 0&&t!==this.lineAnnotations&&(this.setLineAnnotations(t),this.hunksRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations()),this.rerender(),this.interactionManager.setSelectionDirty()}updateRenderCache(e,t,n,r=!1){if(this.hunksRenderer.updateRenderCache(e,t,r)){this.refreshViewTimeout!=null&&(clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=void 0),this.escalateEditSessionRender();return}n&&(this.refreshViewTimeout!=null&&clearTimeout(this.refreshViewTimeout),this.refreshViewTimeout=setTimeout(()=>{this.refreshViewTimeout=void 0,this.options.diffStyle===`split`?this.refreshSplitDiffView():this.refreshUnifiedDiffView(),this.deferSetSelection!=null&&(this.interactionManager.setSelection(...this.deferSetSelection),this.deferSetSelection=void 0)},150))}isLineRenderable(e){let t=this.fileDiffCache;if(t==null)return!0;let{expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options;return Ce({fileDiff:t,lineNumber:e,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r})}getNearestRenderableLine(e,t){let n=this.fileDiffCache;if(n==null)return e;let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options;return l({fileDiff:n,lineNumber:e,direction:t,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i})}revealLine(e){let t=this.fileDiffCache,{expandUnchanged:n=!1,collapsedContextThreshold:r=1,expansionLineCount:i=100}=this.options;if(t==null||t.isPartial||n)return!1;let a=this.hunksRenderer.getExpandedHunksMap();for(let[n,o]of t.hunks.entries()){if(e<o.additionStart){let s=I({isPartial:t.isPartial,rangeSize:o.collapsedBefore,expandedHunks:a,hunkIndex:n,collapsedContextThreshold:r}),c=o.additionStart-s.rangeSize;if(s.renderAll||e<c+s.fromStart||e>=o.additionStart-s.fromEnd)return!1;let l=e-(c+s.fromStart)+1,u=o.additionStart-s.fromEnd-e;return l<=u?this.expandHunk(n,`up`,l+i):this.expandHunk(n,`down`,u+i),!0}if(e<o.additionStart+o.additionCount)return!1}let o=U({fileDiff:t,hunkIndex:t.hunks.length-1,expandedHunks:a,collapsedContextThreshold:r,errorPrefix:`FileDiff.revealLine`});if(o==null||o.renderAll)return!1;let s=t.hunks[t.hunks.length-1],c=s.additionStart+s.additionCount;return e<c+o.fromStart||e>=c+o.rangeSize?!1:(this.expandHunk(t.hunks.length,`up`,e-(c+o.fromStart)+1+i),!0)}shouldSelfHealEditSession(){return this.editor==null}escalateEditSessionRender(){x(this.handleEditSessionRender)}handleEditSessionRender=()=>{this.rerender()};removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){let e=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:`open`});this.placeHolder=document.createElement(`div`),this.placeHolder.dataset.placeholder=``,e.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty(`height`,`${e}px`),!0}async primeHighlightCache(e=this.fileDiff){let{workerManager:t}=this;if(e==null||t==null||!t.isWorkingPool()||e.cacheKey==null||me(e))return;let n=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>n||await t.primeDiffHighlightCache(e).catch(e=>{console.error(e)})}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.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.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=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}renderSeparators(e){let{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!=`function`){for(let{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();return}let n=new Map(this.separatorCache);for(let r of e){let e=r.slotName,i=this.separatorCache.get(e);if(i==null||!xn(r,i.hunkData)){i?.element.remove();let n=document.createElement(`div`);n.style.display=`contents`,n.slot=r.slotName;let a=t(r,this);a!=null&&n.appendChild(a),this.fileContainer.appendChild(n),i={element:n,hunkData:r},this.separatorCache.set(e,i)}n.delete(e)}for(let[e,{element:t}]of n.entries())this.separatorCache.delete(e),t.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(let{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear();return}let e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(let[n,r]of this.lineAnnotations.entries()){let i=`${n}-${O(r)}`,a=this.annotationCache.get(i);if(a==null||!bn(r,a.annotation)){a?.element.remove();let e=t(r);if(e==null)continue;a={element:Be(O(r)),annotation:r},a.element.appendChild(e),this.fileContainer.appendChild(a.element),this.annotationCache.set(i,a)}e.delete(i)}for(let[t,{element:n}]of e.entries())this.annotationCache.delete(t),n.remove()}renderGutterUtility(){let{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}let n=se();n.appendChild(t),this.fileContainer.appendChild(n),this.gutterUtilityContent=n}getOrCreateFileContainer(e,t){let{fileContainer:n}=this,r=e??n??document.createElement(`diffs-container`),i=n!==r;return i&&this.emitPostRender(!0),this.fileContainer=r,n!=null&&i&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),i&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){let{shadowRoot:t}=e;if(t!=null)for(let e of t.children)e instanceof SVGElement?this.spriteSVG??=e:N(e)&&e.hasAttribute(`data-theme-css`)?(this.themeCSSStyle??=e,this.hasAdoptedThemeCSS=!0):N(e)&&e.hasAttribute(`data-unsafe-css`)&&(this.unsafeCSSStyle??=e,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});if(this.spriteSVG==null){let e=document.createElement(`div`);e.innerHTML=de;let t=e.firstChild;t instanceof SVGElement&&(this.spriteSVG=t)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){let t=e.shadowRoot??e.attachShadow({mode:`open`});return this.pre==null?(this.pre=document.createElement(`pre`),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(let t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute(`data-unified`)?this.codeUnified=t:t.hasAttribute(`data-deletions`)?this.codeDeletions=t:t.hasAttribute(`data-additions`)&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;let{fileDiff:n}=this,r=this.cachedHeaderHTML??G(e);if(this.cachedHeaderHTML=r,r!==this.lastRenderedHeaderHTML){let e=document.createElement(`div`);e.innerHTML=r;let n=e.firstElementChild;if(!(n instanceof HTMLElement))return;this.headerElement==null?t.shadowRoot?.prepend(n):t.shadowRoot?.replaceChild(n,this.headerElement),this.headerElement=n,this.lastRenderedHeaderHTML=r}if(this.isContainerManaged||n==null)return;let{renderCustomHeader:i,renderHeaderPrefix:a,renderHeaderFilenameSuffix:o,renderHeaderMetadata:s}=this.options;if(i!=null){let e=i(n)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Oe,e),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}let c=a?.(n)??void 0,l=o?.(n)??void 0,u=s?.(n)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,m,c),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,We,l),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,ee,u),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}let i=t??this.createHeaderSlotElement(n);return t??e.appendChild(i),this.replaceHeaderSlotContent(i,r),i}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){let t=document.createElement(`div`);return t.slot=e,t}injectUnsafeCSS(){let{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??=ve(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=ke(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,n,r){let i=e.shadowRoot??e.attachShadow({mode:`open`}),a=r??n,o=this.options.theme??R,s=typeof o==`string`?o:{...o},c=xe(i);if(this.themeCSSStyle?.parentNode===i&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===a&&this.appliedThemeCSS.scrollbarGutter===c){this.appliedThemeCSS.theme=s;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===i){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c};return}this.themeCSSStyle=De({shadowRoot:i,currentNode:this.themeCSSStyle,themeCSS:je(t,a,c)}),this.appliedThemeCSS=this.themeCSSStyle==null?void 0:{theme:s,themeStyles:t,themeType:a,baseThemeType:r,scrollbarGutter:c}}hydrateMeasuredScrollbar(){let e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=he(this.themeCSSStyle.textContent??``,xe(e)))}applyHunksToDOM(e,t){let{overflow:n=`scroll`}=this.options,r=(this.options.hunkSeparators??`line-info`)===`line-info`,i=n===`wrap`?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let a=!1,o=[],s=this.hunksRenderer.renderCodeAST(`unified`,t),c=this.hunksRenderer.renderCodeAST(`deletions`,t),l=this.hunksRenderer.renderCodeAST(`additions`,t);s==null?c!=null||l!=null?(c==null?(this.codeDeletions?.remove(),this.codeDeletions=void 0):(a=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=ze({code:this.codeDeletions,columnType:`deletions`,rowSpan:i,containerSize:r}),this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(c),o.push(this.codeDeletions)),l==null?(this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=a||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=ze({code:this.codeAdditions,columnType:`additions`,rowSpan:i,containerSize:r}),this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(l),o.push(this.codeAdditions))):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0):(a=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=ze({code:this.codeUnified,columnType:`unified`,rowSpan:i,containerSize:r}),this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(s),o.push(this.codeUnified)),o.length===0?e.textContent=``:a&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){let{pre:n,codeUnified:r,codeAdditions:i,codeDeletions:a,options:{diffStyle:o=`split`}}=this;if(n==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;let s=this.getCodeColumns(o,r,a,i);if(s==null)return!1;let c=e.startingLine,l=t.startingLine,u=c+e.totalLines,d=l+t.totalLines,f=Math.max(c,l),p=Math.min(u,d);if(p<=f)return!1;let m=Math.max(0,f-c),h=Math.max(0,u-p),g=this.trimColumns({columns:s,trimStart:m,trimEnd:h,previousStart:c,overlapStart:f,overlapEnd:p,diffStyle:o});if(g<0)throw Error(`applyPartialRender: failed to trim to overlap`);if(this.lastRowCount<g)throw Error(`applyPartialRender: trimmed beyond DOM row count`);let _=this.lastRowCount-g,v=(e,t)=>{if(!(t<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:e,totalLines:t,bufferBefore:0,bufferAfter:0})},y=v(l,Math.max(f-l,0));if(y==null&&l<f)return!1;let b=v(p,Math.max(d-p,0));if(b==null&&d>p)return!1;let x=(e,t)=>{if(e!=null){if(o===`unified`&&!Array.isArray(s))this.insertPartialHTML(o,s,e,t);else if(o===`split`&&Array.isArray(s))this.insertPartialHTML(o,s,e,t);else throw Error(`FileDiff.applyPartialRender.applyChunk: invalid chunk application`);_+=e.rowCount}};return this.cleanupErrorWrapper(),x(y,`afterbegin`),x(b,`beforeend`),this.lastRowCount!==_&&(this.applyRowSpan(o,s,_),this.lastRowCount=_),!0}insertPartialHTML(e,t,n,r){if(e===`unified`&&!Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`unified`,n);this.renderPartialColumn(t,e,r)}else if(e===`split`&&Array.isArray(t)){let e=this.hunksRenderer.renderCodeAST(`deletions`,n),i=this.hunksRenderer.renderCodeAST(`additions`,n);this.renderPartialColumn(t[0],e,r),this.renderPartialColumn(t[1],i,r)}else throw Error(`FileDiff.insertPartialHTML: Invalid argument composition`)}refreshSplitDiffView(){if(this.options.diffStyle!==`split`)return;let e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;let t=this.getCodeColumns(`split`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(t))return;let n=(t,n)=>{if(n==null)return;let r=this.hunksRenderer.renderCodeAST(t,e),i=$(r?.[0]),a=$(r?.[1]);for(let[e,t]of[[n.gutter,i],[n.content,a]])if(t!=null&&e.childElementCount===t.length)for(let n=0;n<t.length;n++){let r=e.children[n],i=t[n].properties[`data-line-type`];i!=null&&r.dataset.lineType!==i&&(r.dataset.lineType=i)}};n(`deletions`,t[0]),n(`additions`,t[1])}refreshUnifiedDiffView(){if(this.options.diffStyle!==`unified`)return;let e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;let t=this.getCodeColumns(`unified`,this.codeUnified,this.codeDeletions,this.codeAdditions);if(t==null||Array.isArray(t))return;let n=this.hunksRenderer.renderCodeAST(`unified`,e),r=$(n?.[0]),i=$(n?.[1]);for(let[e,n]of[[t.gutter,r],[t.content,i]])n!=null&&(e.innerHTML=G(n));e.rowCount!==this.lastRowCount&&(this.applyRowSpan(`unified`,t,e.rowCount),this.lastRowCount=e.rowCount),this.renderSeparators(e.hunkData),this.managersDirty=!0,this.flushManagers(),this.syncRenderViewToEditor()}renderPartialColumn(e,t,n){if(e==null||t==null)return;let r=$(t[0]),i=$(t[1]);if(r==null||i==null)throw Error(`FileDiff.insertPartialHTML: Unexpected AST structure`);let a=i.at(0);n===`beforeend`&&a?.type===`element`&&typeof a.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(a.properties[`data-buffer-size`],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],r,i,!0);let o=i.at(-1);n===`afterbegin`&&o?.type===`element`&&typeof o.properties[`data-buffer-size`]==`number`&&this.mergeBuffersIfNecessary(o.properties[`data-buffer-size`],e.content.children[0],e.gutter.children[0],r,i,!1),e.gutter.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(r)),e.content.insertAdjacentHTML(n,this.hunksRenderer.renderPartialHTML(i))}mergeBuffersIfNecessary(e,t,n,r,i,a){if(!(t instanceof HTMLElement)||!(n instanceof HTMLElement))return;let o=this.getBufferSize(t.dataset);o!=null&&(a?(r.shift(),i.shift()):(r.pop(),i.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(n,o+e))}applyRowSpan(e,t,n){let r=e=>{e!=null&&(e.gutter.style.setProperty(`grid-row`,`span ${n}`),e.content.style.setProperty(`grid-row`,`span ${n}`))};if(e===`unified`&&!Array.isArray(t))r(t);else if(e===`split`&&Array.isArray(t))r(t[0]),r(t[1]);else throw Error(`dun fuuuuked up`)}trimColumnRows(e,t,n){let r=0,i=0,a=0,o=!1,s=n>=0;if(e==null)return 0;let c=Array.from(e.content.children),l=Array.from(e.gutter.children);if(c.length!==l.length)throw Error(`FileDiff.trimColumnRows: columns do not match`);for(;a<c.length&&!(t<=0&&!s&&!o);){let e=l[a],u=c[a];if(a++,!(e instanceof HTMLElement)||!(u instanceof HTMLElement))throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: invalid row elements`);if(o&&(o=!1,e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset||e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset)){e.remove(),u.remove(),i++;continue}if(`lineIndex`in e.dataset&&`lineIndex`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),t>0&&(t--,t===0&&(o=!0)),i++),r++;continue}if(`separator`in e.dataset&&`separator`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`annotation`&&`lineAnnotation`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`metadata`&&`noNewline`in u.dataset){(t>0||s&&r>=n)&&(e.remove(),u.remove(),i++);continue}if(e.dataset.gutterBuffer===`buffer`&&`contentBuffer`in u.dataset){let a=this.getBufferSize(u.dataset);if(a==null)throw Error(`FileDiff.trimColumnRows: invalid element`);if(t>0){let n=Math.min(t,a),r=a-n;r>0?(this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=n):(e.remove(),u.remove(),i+=a),t-=n,t===0&&r===0&&(o=!0)}else if(s){let t=r,o=r+a-1;if(n<=t)e.remove(),u.remove(),i+=a;else if(n<=o){let t=o-n+1,r=a-t;this.updateBufferSize(e,r),this.updateBufferSize(u,r),i+=t}}r+=a;continue}throw console.error({gutterElement:e,contentElement:u}),Error(`FileDiff.trimColumnRows: unknown row elements`)}return i}trimColumns({columns:e,diffStyle:t,overlapEnd:n,overlapStart:r,previousStart:i,trimEnd:a,trimStart:o}){let s=Math.max(0,r-i),c=n-i;if(c<0)throw Error(`FileDiff.trimColumns: overlap ends before previous`);let l=o>0,u=a>0;if(!l&&!u)return 0;let d=l?s:0,f=u?c:-1;if(t===`unified`&&!Array.isArray(e))return this.trimColumnRows(e,d,f);if(t===`split`&&Array.isArray(e)){let t=this.trimColumnRows(e[0],d,f),n=this.trimColumnRows(e[1],d,f);if(e[0]!=null&&e[1]!=null&&t!==n)throw Error(`FileDiff.trimColumns: split columns out of sync`);return e[0]==null?n:t}else throw console.error({diffStyle:t,columns:e}),Error(`FileDiff.trimColumns: Invalid columns for diffType`)}getBufferSize(e){let t=Number.parseInt(e?.bufferSize??``,10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty(`grid-row`,`span ${t}`),e.style.setProperty(`min-height`,`calc(${t} * 1lh)`)}getCodeColumns(e,t,n,r){function i(e){if(e==null)return;let 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}}if(e===`unified`)return i(t);{let e=i(n),t=i(r);return e!=null||t!=null?[e,t]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}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??(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??(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}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:n,totalLines:r},i){let{diffIndicators:a=`bars`,disableBackground:o=!1,disableLineNumbers:s=!1,overflow:c=`scroll`,diffStyle:l=`split`}=this.options,u={type:`diff`,diffIndicators:a,disableBackground:o,disableLineNumbers:s,overflow:c,split:l===`unified`?!1:t!=null&&n!=null,totalLines:r,customProperties:i};Ge(u,this.appliedPreAttributes)||(Le(e,u),this.appliedPreAttributes=u)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;let n=t.shadowRoot??t.attachShadow({mode:`open`});this.errorWrapper??=document.createElement(`div`),this.errorWrapper.dataset.errorWrapper=``,this.errorWrapper.textContent=``,n.appendChild(this.errorWrapper);let r=document.createElement(`div`);r.dataset.errorMessage=``,r.innerText=e.message,this.errorWrapper.appendChild(r);let i=document.createElement(`pre`);i.dataset.errorStack=``,i.innerText=e.stack??`No Error Stack`,this.errorWrapper.appendChild(i)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function En(e,t){return e==null||t==null?e==null&&t==null:f(e,t)}function Dn({fileDiff:e,oldFile:t,newFile:n}){return e!=null&&e.hunks.length>0||t!=null||n!=null}function On({fileDiff:e,oldFile:t,newFile:n}){return e!=null||t!=null||n!=null}function kn(e,t,n=!1){return!n&&e==null&&t}function An(e,t,n=!1){return e==null&&t&&!n}function $(e){if(!(e==null||e.type!==`element`))return e.children??[]}var jn=3e3,Mn=-1,Nn=class extends Tn{__id=`little-virtualized-file-diff:${++Mn}`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;currentExpandUnchanged;pendingHydratedDiff;pendingExpansions;constructor(e,t,n,r,i=!1){super(e,r,i),this.virtualizer=t,this.metrics=ue(n)}setMetrics(e,t=!1){let n=ue(e);!t&&ae(this.metrics,n)||(this.metrics=n,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache({includeEstimatedHeights:!1})}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}setFileAnnotationHeight(e){let t=this.cache.fileAnnotationHeight;return e===t?!1:(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e=this.fileDiff){return e==null||!S(this.lineAnnotations)?!1:this.lineAnnotations.some(t=>t.lineNumber===0?e.type===`new`?t.side===`additions`:e.type===`deleted`?t.side===`deletions`:!0:!1)}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){let t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.`);if(e==null)return;let{options:t}=this,n=!re(t,e),r=n&&Vn(t,e);super.setOptions(e),r&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Hn(t,e)}),n&&(this.forceRenderOverride=!0),n&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,r)}setThemeType(e){if(this.isAdvancedMode())throw Error(`VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.`);super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1,resetRenderRange:n=!0}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.size>0&&this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal!==0&&(this.cache.measuredHeightDeltaTotal=0),this.invalidateDerivedLayoutCache(t,n),e&&this.isSimpleMode()&&this.computeApproximateSize()}invalidateDerivedLayoutCache(e,t=!0){this.layoutDirty=!0,this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),e&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&t&&(this.renderRange=void 0)}reconcileHeights(){let e=!1,{overflow:t=`scroll`}=this.options;if(this.fileContainer==null||this.fileDiff==null)return this.height!==0&&(e=!0),this.height=0,e;if(this.top=this.getVirtualizedTop(),t===`scroll`&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled())return e;let n=this.getDiffStyle(),r=n===`split`?[this.codeDeletions,this.codeAdditions]:[this.codeUnified],i=this.hasFileAnnotations(this.fileDiff);if(this.renderRange!=null&&i&&T(this.renderRange)){let t=Pn(r)??0;this.setFileAnnotationHeight(t)&&(e=!0)}else!i&&this.setFileAnnotationHeight(0)&&(e=!0);for(let t of r){if(t==null)continue;let r=t.children[1];if(r instanceof HTMLElement)for(let t of r.children){if(!(t instanceof HTMLElement))continue;let r=t.dataset.lineIndex;if(r==null)continue;let i=Kn(r,n),a=t.getBoundingClientRect().height,o=!1;t.nextElementSibling instanceof HTMLElement&&(`lineAnnotation`in t.nextElementSibling.dataset||`noNewline`in t.nextElementSibling.dataset)&&(`noNewline`in t.nextElementSibling.dataset&&(o=!0),a+=t.nextElementSibling.getBoundingClientRect().height);let s=this.getEstimatedLineHeight(o),c=this.cache.heightDeltas.get(i)??0,l=a-s;l!==c&&(e=!0,this.cache.measuredHeightDeltaTotal+=l-c,l===0?this.cache.heightDeltas.delete(i):this.cache.heightDeltas.set(i,l))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render());prepareCodeViewItem(e,t,n,r){let i=!W(this.fileDiff,e),a=this.syncLineAnnotations(r),o=n?.resetDiffLayoutCache===!0||i||a,s=i||n?.resetDiffLayoutCache===!0&&n.includeEstimatedDiffHeights;n?.metrics!=null&&(this.metrics=ue(n.metrics),o=!0,s=!0);let{collapsed:c=!1,expandUnchanged:l=!1}=this.options;return this.currentCollapsed!==c&&(this.currentCollapsed=c,o=!0),this.currentExpandUnchanged!==l&&(this.currentExpandUnchanged=l,o=!0,s=!0),o&&this.resetLayoutCache({includeEstimatedHeights:s}),this.fileDiff=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e,t=`additions`){if(this.fileDiff==null||e<1)return;let n=this.getLineIndex(e,t);if(n==null)return;let{disableFileHeader:r=!1,expandUnchanged:i=!1,collapsed:a=!1,collapsedContextThreshold:o=1}=this.options,s=this.getDiffStyle(),c=this.getHunkSeparatorType(),l=s===`split`?n[1]:n[0];this.approximateLayoutCheckpoints();let u=H(this.metrics,r),d=this.getLayoutCheckpointBeforeLineIndex(l),f=d?.top??u+this.cache.fileAnnotationHeight;if(a)return{top:u,height:0};let p;return F({diff:this.fileDiff,diffStyle:s,startingLine:d?.renderedLineIndex??0,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:e,hunk:t,collapsedBefore:n,collapsedAfter:r,deletionLine:i,additionLine:a})=>{let o=s===`split`?a?.splitLineIndex??i?.splitLineIndex:a?.unifiedLineIndex??i?.unifiedLineIndex;if(o==null)throw Error(`VirtualizedFileDiff.getLinePosition: missing line index data`);if(n>0){let r=M({type:c,metrics:this.metrics,hunkIndex:e,hunkSpecs:t?.hunkSpecs});if(r!=null){if(f+=r.gapBefore,l>=o-n&&l<o)return p={top:f,height:r.height},!0;f+=r.height+r.gapAfter}}let u=this.getLineHeight(o,(a?.noEOFCR??!1)||(i?.noEOFCR??!1));if(o===l)return p={top:f,height:u},!0;if(f+=u,r>0){let e=V({type:c,metrics:this.metrics});if(e!=null){if(l>o&&l<=o+r)return p={top:f+e.gapBefore,height:e.height},!0;f+=e.totalHeight}}return!1}}),p}getScrollContainer(){let e=this.getSimpleVirtualizer()?.getRoot();return e instanceof HTMLElement?e:e?.documentElement}getNumericScrollAnchor(e){if(this.fileDiff==null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsed:r=!1,collapsedContextThreshold:i=1}=this.options;if(r)return;let a=this.getDiffStyle(),o=this.getHunkSeparatorType();this.approximateLayoutCheckpoints();let s=this.getLayoutCheckpointBeforeTop(e),c=s?.top??H(this.metrics,t)+this.cache.fileAnnotationHeight,l;return F({diff:this.fileDiff,diffStyle:a,startingLine:s?.renderedLineIndex??0,expandedHunks:n?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i,callback:({hunkIndex:t,hunk:n,collapsedBefore:r,collapsedAfter:i,deletionLine:s,additionLine:u})=>{let d=a===`split`?u?.splitLineIndex??s?.splitLineIndex:u?.unifiedLineIndex??s?.unifiedLineIndex;if(d==null)throw Error(`VirtualizedFileDiff.getNumericScrollAnchor: missing line index data`);if(r>0){let e=M({type:o,metrics:this.metrics,hunkIndex:t,hunkSpecs:n?.hunkSpecs});e!=null&&(c+=e.totalHeight)}if(c>=e&&(s==null?u!=null&&(l={lineNumber:u.lineNumber,side:`additions`,top:c}):l={lineNumber:s.lineNumber,side:`deletions`,top:c},l!=null))return!0;let f=this.getLineHeight(d,(u?.noEOFCR??!1)||(s?.noEOFCR??!1));if(c+=f,i>0){let e=V({type:o,metrics:this.metrics});e!=null&&(c+=e.totalHeight)}return!1}}),l}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.fileDiff==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};let t=e==null?this.renderRange:this.computeRenderRangeFromWindow(this.fileDiff,this.top,e);if(t==null)return;let{bufferBefore:n,bufferAfter:r,totalLines:i}=t,a=0;if(i===0){let t=e??this.virtualizer.getWindowSpecs();this.top<t.top&&(a=r)}return{topOffset:this.top+n+a,height:this.height-(n+r)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||(this.resetLayoutCache({includeEstimatedHeights:!0}),this.pendingExpansions=void 0,this.pendingHydratedDiff=void 0),this.isSetup=!1,super.cleanUp(e)}expandHunk=(e,t,n)=>{this.fileDiff!=null&&(this.isAdvancedMode()?(this.pendingExpansions??=[],this.pendingExpansions.push({hunkIndex:e,direction:t,expansionLineCountOverride:n})):(this.hunksRenderer.expandHunk(e,t,n),this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()),this.loadFilesIfNecessary(),this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))};async handleFilesLoaded(e,t){if(!(this.fileDiff!==e||!e.isPartial)){if(this.isAdvancedMode()){let n=Vt(`clone`,e,t);if(await Pt(()=>this.primeHighlightCache(n)),!this.enabled||this.fileDiff!==e)return;this.pendingHydratedDiff={expectedDiff:e,nextDiff:n,files:t}}else{if(Vt(`merge`,e,t),this.setHydratedState(t),await Pt(()=>this.primeHighlightCache(e)),!this.enabled||this.fileDiff!==e)return;this.resetLayoutCache({includeEstimatedHeights:!0}),this.computeApproximateSize()}this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0)}}consumeCodeViewLayoutChanges(e){let t=!1,n,{pendingExpansions:r,pendingHydratedDiff:i}=this;if(r!=null){this.pendingExpansions=void 0;for(let e of r)this.hunksRenderer.expandHunk(e.hunkIndex,e.direction,e.expansionLineCountOverride),t=!0}return i!=null&&(this.pendingHydratedDiff=void 0,i.expectedDiff===e&&(this.setHydratedState(i.files),n=i.nextDiff)),n==null?t&&(this.forceRenderOverride=!0,this.invalidateDerivedLayoutCache(!0)):(this.forceRenderOverride=!0,this.resetLayoutCache({includeEstimatedHeights:!0})),n}loadFilesIfNecessary(){if(this.pendingHydratedDiff!=null){if(this.pendingHydratedDiff.expectedDiff===this.fileDiff)return;this.pendingHydratedDiff=void 0}super.loadFilesIfNecessary()}isLineRenderable(e){if(super.isLineRenderable(e))return!0;let{pendingExpansions:t}=this,n=this.fileDiffCache;if(t==null||t.length===0||n==null)return!1;let{expansionLineCount:r=100,collapsedContextThreshold:i=1}=this.options,a=new Map(this.hunksRenderer.getExpandedHunksMap());for(let e of t){let t={...a.get(e.hunkIndex)??{fromStart:0,fromEnd:0}},n=e.expansionLineCountOverride??r;(e.direction===`up`||e.direction===`both`)&&(t.fromStart+=n),(e.direction===`down`||e.direction===`both`)&&(t.fromEnd+=n),a.set(e.hunkIndex,t)}return Ce({fileDiff:n,lineNumber:e,expandedHunks:a,collapsedContextThreshold:i})}invalidateEditSessionLayout(){this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),this.getSimpleVirtualizer()?.requestHeightReconcile(this)}escalateEditSessionRender(){this.invalidateEditSessionLayout(),!(!this.enabled||this.fileDiff==null)&&(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!0))}shouldSelfHealEditSession(){return!this.isAdvancedMode()&&super.shouldSelfHealEditSession()}setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,n=!1){let r=this.renderRange;if(super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0,resetRenderRange:!1}),this.isSimpleMode()||this.computeApproximateSize(!0),n&&r!==void 0&&this.fileDiff!==void 0){let e=this.virtualizer.getWindowSpecs(),t=this.computeRenderRangeFromWindow(this.fileDiff,this.top??0,e);t.bufferAfter!==r.bufferAfter&&this.updateBuffers(t)}}computeApproximateSize(e=!1,t=this.fileDiff){let n=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!n)return;let r=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,t==null){this.layoutDirty=!1;return}let{disableFileHeader:i=!1,collapsed:a=!1}=this.options,o=H(this.metrics,i);if(this.height+=o,a){this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight(t)+this.cache.measuredHeightDeltaTotal,n&&!r&&this.validateComputedHeight(t),this.layoutDirty=!1}getActiveEstimatedHeight(e=this.fileDiff){this.ensureEstimatedDiffHeights(e);let t=this.getDiffStyle()===`split`?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(t==null)throw Error(`VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height`);return t}ensureEstimatedDiffHeights(e=this.fileDiff){if(e==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,{splitHeight:i,unifiedHeight:a}=Ft({fileDiff:e,metrics:this.metrics,disableFileHeader:t,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:n,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:r,canHydratePartialDiff:Un(e,this.options.loadDiffFiles!=null)});this.cache.estimatedSplitHeight=i,this.cache.estimatedUnifiedHeight=a}validateComputedHeight(e=this.fileDiff){if(this.fileContainer==null||e==null)return;let t=this.fileContainer.getBoundingClientRect();t.height===this.height?console.log(`VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT`):console.log(`VirtualizedFileDiff.computeApproximateSize: computed height doesnt match`,{name:e.name,elementHeight:t.height,computedHeight:this.height})}render({fileContainer:e,fileDiff:t,forceRender:n=!1,lineAnnotations:r,...i}={}){let a=Rt(i,`VirtualizedFileDiff.render`),o=a!=null,s=a?.oldFile,c=a?.newFile,l=o&&(!Gn(s,this.deletionFile)||!Gn(c,this.additionFile)),u=t??this.fileDiff;t==null&&o&&(l||this.fileDiff==null)&&(u=Y(a.oldFile,a.newFile,this.options.parseDiffOptions));let{forceRenderOverride:d,isSetup:f}=this;this.forceRenderOverride=void 0;let p=this.syncLineAnnotations(r);p&&this.resetLayoutCache({includeEstimatedHeights:!1});let m=t!=null&&t!==this.fileDiff,h=u!=null&&!W(this.fileDiff,u),g=m||l;if(h&&this.resetLayoutCache({includeEstimatedHeights:!0}),e=this.getOrCreateFileContainer(e),u==null)return console.error(`VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data`),!1;if(f)this.top??=this.getVirtualizedTop(),h&&this.computeApproximateSize(!1,u);else{this.computeApproximateSize(!1,u);let t=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(t==null)throw Error(`VirtualizedFileDiff.render: simple virtualizer is not available`);t.connect(e,this),this.isVisible=t.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode()&&(!g||!f))return this.fileDiff=u,a!=null&&(this.deletionFile=s,this.additionFile=c),h&&(this.cachedHeaderHTML=void 0),this.renderPlaceholder(this.height);let _=this.virtualizer.getWindowSpecs(),v=this.top??0,y=this.computeRenderRangeFromWindow(u,v,_),b=super.render({fileDiff:u,fileContainer:e,renderRange:y,lineAnnotations:r,forceRender:(d??n)||p||h,...a,...i});return this.isSimpleMode()&&b&&this.getSimpleVirtualizer()?.requestHeightReconcile(this),b}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type===`simple`}isAdvancedMode(){return this.virtualizer.type===`advanced`}getVirtualizedTop(){return this.virtualizer.type===`advanced`?this.virtualizer.getLocalTopForInstance(this):this.fileContainer==null?0:this.virtualizer.getOffsetInScrollContainer(this.fileContainer)}getSimpleVirtualizer(){return this.virtualizer.type===`simple`?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??`split`}getHunkSeparatorType(){return Wn(this.options.hunkSeparators)}approximateLayoutCheckpoints(e=this.fileDiff){if(!this.layoutDirty&&this.cache.checkpoints.length>0||e==null||e.hunks.length===0||this.options.collapsed===!0)return;let{disableFileHeader:t=!1,expandUnchanged:n=!1,collapsedContextThreshold:r=1}=this.options,i=e.hunks.length-1,a=Un(e,this.options.loadDiffFiles!=null),o=this.getDiffStyle(),s=this.getHunkSeparatorType(),c=n?!0:this.hunksRenderer.getExpandedHunksMap(),l=Fn(this.cache.heightDeltas),u=H(this.metrics,t)+this.cache.fileAnnotationHeight,d=0,f=({rowCount:e,startLineIndex:t,preSeparatorHeight:n=0,postSeparatorHeight:r=0,metadataOffsets:i=[]})=>{if(e<=0)return;let a=d,o=d+e,s=Rn(a);for(;s<o;){let e=s-a,r=u+(e>0?n:0)+e*this.metrics.lineHeight+zn(i,e)*this.metrics.lineHeight+In(l,t,t+e);this.cache.checkpoints.push({renderedLineIndex:s,lineIndex:t+e,top:r}),s+=jn}u+=n+e*this.metrics.lineHeight+i.length*this.metrics.lineHeight+In(l,t,t+e)+r,d=o};for(let t=0;t<e.hunks.length;t++){let n=e.hunks[t];if(n==null)throw Error(`VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index`);let l=I({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:c,hunkIndex:t,collapsedContextThreshold:r}),u=l.collapsedLines>0?M({type:s,metrics:this.metrics,hunkIndex:t,hunkSpecs:n.hunkSpecs})?.totalHeight??0:0;f({rowCount:l.fromStart,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.rangeSize});let d=u;f({rowCount:l.fromEnd,startLineIndex:(o===`split`?n.splitLineStart:n.unifiedLineStart)-l.fromEnd,preSeparatorHeight:d}),l.fromEnd>0&&(d=0);let p=t===i?U({fileDiff:e,hunkIndex:t,expandedHunks:c,collapsedContextThreshold:r,errorPrefix:`VirtualizedFileDiff`}):void 0,m=p!=null&&p.collapsedLines>0||t===i&&a?V({type:s,metrics:this.metrics})?.totalHeight??0:0,h=p==null?0:p.fromStart+p.fromEnd,g=o===`split`?n.splitLineCount:n.unifiedLineCount,_=o===`split`?n.splitLineStart:n.unifiedLineStart;f({rowCount:g,startLineIndex:_,preSeparatorHeight:d,postSeparatorHeight:h===0?m:0,metadataOffsets:Bn({diffStyle:o,hunk:n,rowCount:g})}),p!=null&&h>0&&f({rowCount:h,startLineIndex:_+g,postSeparatorHeight:m})}this.cache.totalLines=d}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,n=this.cache.checkpoints.length-1,r;for(;t<=n;){let i=t+n>>1,a=this.cache.checkpoints[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.lineIndex<=e?(r=a,t=i+1):n=i-1}return r}getLayoutCheckpointBeforeTop(e,t){let n=0,r=this.cache.checkpoints.length-1,i=-1;for(;n<=r;){let t=n+r>>1,a=this.cache.checkpoints[t];if(a==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);a.top<=e?(i=t,n=t+1):r=t-1}if(t==null)return i>=0?this.cache.checkpoints[i]:void 0;for(let e=i;e>=0;e--){let n=this.cache.checkpoints[e];if(n==null)throw Error(`VirtualizedFileDiff: invalid checkpoint index`);if(n.renderedLineIndex%t===0)return n}}getExpandedLineCount(e,t){let n=0;if(e.isPartial){for(let r of e.hunks)n+=t===`split`?r.splitLineCount:r.unifiedLineCount;return n}let{expandUnchanged:r=!1,collapsedContextThreshold:i=1}=this.options,a=r?!0:this.hunksRenderer.getExpandedHunksMap();for(let[r,o]of e.hunks.entries()){let s=t===`split`?o.splitLineCount:o.unifiedLineCount;n+=s;let c=Math.max(o.collapsedBefore,0),{fromStart:l,fromEnd:u,renderAll:d}=I({isPartial:e.isPartial,rangeSize:c,expandedHunks:a,hunkIndex:r,collapsedContextThreshold:i});c>0&&(n+=d?c:l+u)}let o=U({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:a,collapsedContextThreshold:i,errorPrefix:`VirtualizedFileDiff`});return o!=null&&(n+=o.fromStart+o.fromEnd),n}getLayoutLineCount(e,t){let n=this.getExpandedLineCount(e,t),r=t===`split`?e.splitLineCount:e.unifiedLineCount;return Math.max(n,r,e.additionLines.length,e.deletionLines.length,this.cache.totalLines)}computeRenderRangeFromWindow(e,t,{top:n,bottom:r}){let{disableFileHeader:i=!1,expandUnchanged:a=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:s,lineHeight:c}=this.metrics,l=this.getDiffStyle(),u=this.getHunkSeparatorType(),d=Un(e,this.options.loadDiffFiles!=null),f=this.height,p=this.getLayoutLineCount(e,l),m=H(this.metrics,i),h=e.hunks.length>0?Re(this.metrics):0,{fileAnnotationHeight:g}=this.cache,_=m+g,v=Math.max(0,f-m-g-h),y=this.hasFileAnnotations(e),b=t+m,x=g>0&&y&&b<r&&b+g>n;if(t<n-f||t>r)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h};if(p<=s||e.hunks.length===0)return{startingLine:0,totalLines:s,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(e),p=this.getLayoutLineCount(e,l);let S=Math.ceil(Math.max(r-n,0)/c),C=Math.ceil(S/s)*s+s,w=C/s,T=w,E=[],D=(n+r)/2,O=this.getLayoutCheckpointBeforeTop(Math.max(0,n-t-C*c*2),s),k=t+(O?.top??_),A=O?.renderedLineIndex??0,j,N,P;if(F({diff:e,diffStyle:l,startingLine:O?.renderedLineIndex??0,expandedHunks:a?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:i,hunk:a,collapsedBefore:o,collapsedAfter:c,deletionLine:f,additionLine:p})=>{let m=p==null?f.splitLineIndex:p.splitLineIndex,h=p==null?f.unifiedLineIndex:p.unifiedLineIndex,g=(p?.noEOFCR??!1)||(f?.noEOFCR??!1),v=i===e.hunks.length-1&&a!=null&&(l===`split`?m===a.splitLineStart+a.splitLineCount-1:h===a.unifiedLineStart+a.unifiedLineCount-1),y=(o>0?M({type:u,metrics:this.metrics,hunkIndex:i,hunkSpecs:a?.hunkSpecs}):void 0)?.totalHeight??0;k+=y;let b=A%s===0,x=Math.floor(A/s);if(b&&(E[x]=k-(t+_+y),P!=null)){if(P<=0)return!0;P--}let S=this.getLineHeight(l===`split`?m:h,g);if(k>n-S&&k<r&&(j??=x),N==null&&k+S>D&&(N=x),P==null&&k>=r&&b&&(P=T),A++,k+=S,c>0||v&&d){let e=V({type:u,metrics:this.metrics});e!=null&&(k<r&&k+e.totalHeight>n&&(j??=x),N==null&&k+e.totalHeight>D&&(N=x),k+=e.totalHeight)}return!1}}),j==null)if(x)j=0,N=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:f-m-h};N??=j;let ee=Math.round(N-w/2),te=Math.max(0,Math.ceil(p/s)-w),ne=Math.max(0,Math.min(ee,te)),re=ne*s,ie=ee<0?C+ee*s:C,ae=E[ne]??0,oe=re===0?0:g+ae,I=ne+ie/s,se=I<E.length?v-E[I]:v-(k-t-_);return{startingLine:re,totalLines:ie,bufferBefore:oe,bufferAfter:Math.max(0,se)}}};function Pn(e){let t;for(let n of e){if(n==null)continue;let e=n.children[1];if(e instanceof HTMLElement)for(let n of e.children)n instanceof HTMLElement&&n.dataset.lineAnnotation===A&&(t=Math.max(t??0,n.getBoundingClientRect().height))}return t}function Fn(e){let t=Array.from(e).sort((e,t)=>e[0]-t[0]),n=[],r=[0],i=0;for(let[e,a]of t)n.push(e),i+=a,r.push(i);return{lineIndexes:n,prefixTotals:r}}function In({lineIndexes:e,prefixTotals:t},n,r){if(n>=r||e.length===0)return 0;let i=Ln(e,n);return(t[Ln(e,r)]??0)-(t[i]??0)}function Ln(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(a==null)throw Error(`VirtualizedFileDiff: invalid prefix index`);a<t?n=i+1:r=i}return n}function Rn(e){return Math.ceil(e/jn)*jn}function zn(e,t){let n=0;for(let r of e)r<t&&n++;return n}function Bn({diffStyle:e,hunk:t,rowCount:n}){if(n<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];let r=t.hunkContent.at(-1);if(r==null)return[];if(r.type===`context`)return[n-1];let i=Math.max(r.deletions,r.additions),a=r.deletions+r.additions;if(e===`split`)return i>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[n-1]:[];let o=[],s=n-a;return r.deletions>0&&t.noEOFCRDeletions&&o.push(s+r.deletions-1),r.additions>0&&t.noEOFCRAdditions&&o.push(n-1),o}function Vn(e,t){return(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??`bars`)!==(t.diffIndicators??`bars`)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function Hn(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??`line-info`)!==(t.hunkSeparators??`line-info`)||!!e.loadDiffFiles!=!!t.loadDiffFiles||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function Un(e,t){return e.isPartial&&t&&(e.type===`change`||e.type===`rename-changed`)}function Wn(e){return typeof e==`function`?`custom`:e??`line-info`}function Gn(e,t){return e==null||t==null?e==null&&t==null:f(e,t)}function Kn(e,t){let[n,r]=e.split(`,`).map(Number);return t===`split`?r:n}function qn(e){return new Worker(`/assets/worker-CIcqvLjo.js`,{name:e?.name})}var Jn=e(i(),1),Yn=class extends t()(`DiffWorkerError`,{operation:n([`create-worker`,`get-render-options`,`set-render-options`]),themeName:n([`pierre-light`,`pierre-dark`]),cause:r()}){get message(){return`Diff worker operation ${this.operation} failed for theme ${this.themeName}.`}};function Xn(e){let t=(0,K.c)(4),{themeName:n}=e,r=Pe(),i,a;return t[0]!==n||t[1]!==r?(i=()=>{if(!r)return;let e=`get-render-options`;(async()=>{try{let t=r.getDiffRenderOptions();if(t.theme===n)return;e=`set-render-options`,await r.setRenderOptions({...t,theme:n})}catch(t){console.error(new Yn({operation:e,themeName:n,cause:t}))}})()},a=[n,r],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),(0,Jn.useEffect)(i,a),null}function Zn(e){let t=(0,K.c)(11),{children:n}=e,{resolvedTheme:r}=c(),i;t[0]===r?i=t[1]:(i=u(r),t[0]=r,t[1]=i);let a=i,o=typeof navigator>`u`?4:Math.max(1,navigator.hardwareConcurrency||4),s=Math.max(2,Math.min(6,Math.floor(o/2))),l,d,f;t[2]===a?(l=t[3],d=t[4],f=t[5]):(l={workerFactory:()=>{try{return new qn}catch(e){throw new Yn({operation:`create-worker`,themeName:a,cause:e})}},poolSize:s,totalASTLRUCacheSize:240},d={theme:a,tokenizeMaxLineLength:1e3,useTokenTransformer:!0},f=(0,q.jsx)(Xn,{themeName:a}),t[2]=a,t[3]=l,t[4]=d,t[5]=f);let p;return t[6]!==n||t[7]!==l||t[8]!==d||t[9]!==f?(p=(0,q.jsxs)(w,{poolOptions:l,highlighterOptions:d,children:[f,n]}),t[6]=n,t[7]=l,t[8]=d,t[9]=f,t[10]=p):p=t[10],p}export{Rt as a,tt as c,J as d,an as i,Ze as l,Nn as n,kt as o,Tn as r,Y as s,Zn as t,Je as u};
10
- //# sourceMappingURL=DiffWorkerPoolProvider-_R9JGgmp.js.map
@@ -1,17 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/lib-DyhHMOev.js","assets/rolldown-runtime-DAXXjFlN.js","assets/main-DFDCV-Ns.js","assets/index-BKWzfr1Y.js","assets/index-DZprGaeP.css","assets/useLocalStorage-2W_I13tQ.js","assets/utils-D0kLIGeh.js","assets/session-DIGL5_Nm.js","assets/queries-x5LGu_Fy.js","assets/textarea-DdNchuIO.js","assets/clientPersistenceStorage-DSC61yLx.js","assets/designOpenFileContext-CCQs4ovB.js","assets/empty-DynqTxIR.js","assets/input-Q4KA45-f.js","assets/browserRecording-DrMz1iOt.js","assets/RightPanelResizeHandle-DZdzK7y3.js","assets/browserHistoryStore-K9gWOOUq.js","assets/entities-dwE_i4XM.js","assets/env-DgM3kOA4.js","assets/ArrowRight-BOicMyF9.js","assets/ArrowSquareOut-D7Y2Tt3L.js","assets/scroll-area-D8MfzXjN.js","assets/lib-BpnzBIoA.js","assets/ArrowsClockwise-DycxhEkt.js","assets/ChatMarkdown-Cl8M9HCx.js","assets/assetUrls-BBFxUocf.js","assets/lib-CCiVGdun.js","assets/designCanvas.logic-DuuhotDy.js","assets/designCanvas-CfWhq9nr.css","assets/CaretLeft-CDMA3Uas.js","assets/toggle-CmeCFqd7.js","assets/PullRequestReactions-BWjOU4KY.js","assets/popover-CXGEm4M0.js","assets/composerMentionDrag-D06cCeGC.js","assets/combobox-C4C8XR-w.js","assets/useWorkspaceMutationRefresh-YuIxWftk.js","assets/DiffWorkerPoolProvider-_R9JGgmp.js","assets/toggle-group-iEMUfMdW.js","assets/projectFilesQueryState-7mFyaRdj.js","assets/spinner-CwxxMzkd.js","assets/zipGuard-BHHl8sLU.js","assets/main-CI0aXqkB.css"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./index-BKWzfr1Y.js";import{a as n}from"./useLocalStorage-2W_I13tQ.js";import{Bo as r,wo as i}from"./utils-D0kLIGeh.js";import{t as a}from"./lib-BpnzBIoA.js";import{t as o}from"./spinner-CwxxMzkd.js";import{t as s}from"./documentBytes-CS3KpytE.js";import{c,d as l,g as u,n as d,s as f,t as p,u as m}from"./lib-CCiVGdun.js";var h={abandonedHeadElementChild:{reason:`Unexpected metadata element after head`,description:"Unexpected element after head. Expected the element before `</head>`",url:!1},abruptClosingOfEmptyComment:{reason:`Unexpected abruptly closed empty comment`,description:"Unexpected `>` or `->`. Expected `-->` to close comments"},abruptDoctypePublicIdentifier:{reason:`Unexpected abruptly closed public identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the public identifier"},abruptDoctypeSystemIdentifier:{reason:`Unexpected abruptly closed system identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the identifier identifier"},absenceOfDigitsInNumericCharacterReference:{reason:`Unexpected non-digit at start of numeric character reference`,description:"Unexpected `%c`. Expected `[0-9]` for decimal references or `[0-9a-fA-F]` for hexadecimal references"},cdataInHtmlContent:{reason:`Unexpected CDATA section in HTML`,description:"Unexpected `<![CDATA[` in HTML. Remove it, use a comment, or encode special characters instead"},characterReferenceOutsideUnicodeRange:{reason:`Unexpected too big numeric character reference`,description:`Unexpectedly high character reference. Expected character references to be at most hexadecimal 10ffff (or decimal 1114111)`},closingOfElementWithOpenChildElements:{reason:`Unexpected closing tag with open child elements`,description:`Unexpectedly closing tag. Expected other tags to be closed first`,url:!1},controlCharacterInInputStream:{reason:`Unexpected control character`,description:"Unexpected control character `%x`. Expected a non-control code point, 0x00, or ASCII whitespace"},controlCharacterReference:{reason:`Unexpected control character reference`,description:`Unexpectedly control character in reference. Expected a non-control code point, 0x00, or ASCII whitespace`},disallowedContentInNoscriptInHead:{reason:"Disallowed content inside `<noscript>` in `<head>`",description:"Unexpected text character `%c`. Only use text in `<noscript>`s in `<body>`",url:!1},duplicateAttribute:{reason:`Unexpected duplicate attribute`,description:`Unexpectedly double attribute. Expected attributes to occur only once`},endTagWithAttributes:{reason:`Unexpected attribute on closing tag`,description:"Unexpected attribute. Expected `>` instead"},endTagWithTrailingSolidus:{reason:`Unexpected slash at end of closing tag`,description:"Unexpected `%c-1`. Expected `>` instead"},endTagWithoutMatchingOpenElement:{reason:`Unexpected unopened end tag`,description:`Unexpected end tag. Expected no end tag or another end tag`,url:!1},eofBeforeTagName:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected tag name instead`},eofInCdata:{reason:`Unexpected end of file in CDATA`,description:"Unexpected end of file. Expected `]]>` to close the CDATA"},eofInComment:{reason:`Unexpected end of file in comment`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInDoctype:{reason:`Unexpected end of file in doctype`,description:"Unexpected end of file. Expected a valid doctype (such as `<!doctype html>`)"},eofInElementThatCanContainOnlyText:{reason:`Unexpected end of file in element that can only contain text`,description:`Unexpected end of file. Expected text or a closing tag`,url:!1},eofInScriptHtmlCommentLikeText:{reason:`Unexpected end of file in comment inside script`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInTag:{reason:`Unexpected end of file in tag`,description:"Unexpected end of file. Expected `>` to close the tag"},incorrectlyClosedComment:{reason:`Incorrectly closed comment`,description:"Unexpected `%c-1`. Expected `-->` to close the comment"},incorrectlyOpenedComment:{reason:`Incorrectly opened comment`,description:"Unexpected `%c`. Expected `<!--` to open the comment"},invalidCharacterSequenceAfterDoctypeName:{reason:`Invalid sequence after doctype name`,description:"Unexpected sequence at `%c`. Expected `public` or `system`"},invalidFirstCharacterOfTagName:{reason:`Invalid first character in tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},misplacedDoctype:{reason:`Misplaced doctype`,description:`Unexpected doctype. Expected doctype before head`,url:!1},misplacedStartTagForHeadElement:{reason:"Misplaced `<head>` start tag",description:"Unexpected start tag `<head>`. Expected `<head>` directly after doctype",url:!1},missingAttributeValue:{reason:`Missing attribute value`,description:"Unexpected `%c-1`. Expected an attribute value or no `%c-1` instead"},missingDoctype:{reason:`Missing doctype before other content`,description:"Expected a `<!doctype html>` before anything else",url:!1},missingDoctypeName:{reason:`Missing doctype name`,description:"Unexpected doctype end at `%c`. Expected `html` instead"},missingDoctypePublicIdentifier:{reason:`Missing public identifier in doctype`,description:"Unexpected `%c`. Expected identifier for `public` instead"},missingDoctypeSystemIdentifier:{reason:`Missing system identifier in doctype`,description:'Unexpected `%c`. Expected identifier for `system` instead (suggested: `"about:legacy-compat"`)'},missingEndTagName:{reason:`Missing name in end tag`,description:"Unexpected `%c`. Expected an ASCII letter instead"},missingQuoteBeforeDoctypePublicIdentifier:{reason:`Missing quote before public identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingQuoteBeforeDoctypeSystemIdentifier:{reason:`Missing quote before system identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingSemicolonAfterCharacterReference:{reason:`Missing semicolon after character reference`,description:"Unexpected `%c`. Expected `;` instead"},missingWhitespaceAfterDoctypePublicKeyword:{reason:`Missing whitespace after public identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceAfterDoctypeSystemKeyword:{reason:`Missing whitespace after system identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBeforeDoctypeName:{reason:`Missing whitespace before doctype name`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenAttributes:{reason:`Missing whitespace between attributes`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers:{reason:`Missing whitespace between public and system identifiers in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},nestedComment:{reason:`Unexpected nested comment`,description:"Unexpected `<!--`. Expected `-->`"},nestedNoscriptInHead:{reason:"Unexpected nested `<noscript>` in `<head>`",description:"Unexpected `<noscript>`. Expected a closing tag or a meta element",url:!1},nonConformingDoctype:{reason:`Unexpected non-conforming doctype declaration`,description:'Expected `<!doctype html>` or `<!doctype html system "about:legacy-compat">`',url:!1},nonVoidHtmlElementStartTagWithTrailingSolidus:{reason:`Unexpected trailing slash on start tag of non-void element`,description:"Unexpected `/`. Expected `>` instead"},noncharacterCharacterReference:{reason:`Unexpected noncharacter code point referenced by character reference`,description:`Unexpected code point. Do not use noncharacters in HTML`},noncharacterInInputStream:{reason:`Unexpected noncharacter character`,description:"Unexpected code point `%x`. Do not use noncharacters in HTML"},nullCharacterReference:{reason:`Unexpected NULL character referenced by character reference`,description:`Unexpected code point. Do not use NULL characters in HTML`},openElementsLeftAfterEof:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected closing tag instead`,url:!1},surrogateCharacterReference:{reason:`Unexpected surrogate character referenced by character reference`,description:`Unexpected code point. Do not use lone surrogate characters in HTML`},surrogateInInputStream:{reason:`Unexpected surrogate character`,description:"Unexpected code point `%x`. Do not use lone surrogate characters in HTML"},unexpectedCharacterAfterDoctypeSystemIdentifier:{reason:`Invalid character after system identifier in doctype`,description:"Unexpected character at `%c`. Expected `>`"},unexpectedCharacterInAttributeName:{reason:`Unexpected character in attribute name`,description:"Unexpected `%c`. Expected whitespace, `/`, `>`, `=`, or probably an ASCII letter"},unexpectedCharacterInUnquotedAttributeValue:{reason:`Unexpected character in unquoted attribute value`,description:"Unexpected `%c`. Quote the attribute value to include it"},unexpectedEqualsSignBeforeAttributeName:{reason:`Unexpected equals sign before attribute name`,description:"Unexpected `%c`. Add an attribute name before it"},unexpectedNullCharacter:{reason:`Unexpected NULL character`,description:"Unexpected code point `%x`. Do not use NULL characters in HTML"},unexpectedQuestionMarkInsteadOfTagName:{reason:`Unexpected question mark instead of tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},unexpectedSolidusInTag:{reason:`Unexpected slash in tag`,description:"Unexpected `%c-1`. Expected it followed by `>` or in a quoted attribute value"},unknownNamedCharacterReference:{reason:`Unexpected unknown named character reference`,description:`Unexpected character reference. Expected known named character references`}},g=`https://html.spec.whatwg.org/multipage/parsing.html#parse-error-`,_=/-[a-z]/g,v=/%c(?:([-+])(\d+))?/g,y=/%x/g,b={2:!0,1:!1,0:null},x={};function S(e,t){let n=t||x,r=n.onerror,i=e instanceof f?e:new f(e),a=n.fragment?l:m,o=String(i);return u(a(o,{sourceCodeLocationInfo:!0,onParseError:n.onerror?s:null,scriptingEnabled:!1}),{file:i,space:n.space,verbose:n.verbose});function s(e){let t=e.code,a=C(t),s=n[a]??!0,l=typeof s==`number`?s:+!!s;if(l){let n=h[a],o=new c(u(n.reason),{place:{start:{line:e.startLine,column:e.startCol,offset:e.startOffset},end:{line:e.endLine,column:e.endCol,offset:e.endOffset}},ruleId:t,source:`hast-util-from-html`});i.path&&(o.file=i.path,o.name=i.path+`:`+o.name),o.fatal=b[l],o.note=u(n.description),o.url=n.url===!1?void 0:g+t,r(o)}function u(t){return t.replace(v,n).replace(y,r);function n(t,n,r){let i=(r?Number.parseInt(r,10):0)*(n===`-`?-1:1);return T(o.charAt(e.startOffset+i))}function r(){return E(o.charCodeAt(e.startOffset))}}}}function C(e){return e.replace(_,w)}function w(e){return e.charAt(1).toUpperCase()}function T(e){return e==="`"?"` ` `":e}function E(e){return`0x`+e.toString(16).toUpperCase()}var D=e(n(),1),O=i(),k=new Set([`embed`,`form`,`iframe`,`input`,`object`,`script`,`style`]),A={...d,strip:[...d.strip??[],`style`,`title`],attributes:{...d.attributes,"*":(d.attributes?.[`*`]??[]).filter(e=>e!==`title`)},protocols:{...d.protocols,href:[`http`,`https`,`mailto`],src:[`data`]},tagNames:(d.tagNames??[]).filter(e=>!k.has(e))};function j(e){return a(p(S(e,{fragment:!0}),A))}var M=r(),N=`
3
- :root { color-scheme: light; }
4
- body {
5
- background: #fff;
6
- color: #1a1a1a;
7
- font: 15px/1.6 ui-sans-serif, system-ui, sans-serif;
8
- margin: 0;
9
- padding: 2rem;
10
- }
11
- img { height: auto; max-width: 100%; }
12
- table { border-collapse: collapse; }
13
- td, th { border: 1px solid #d4d4d4; padding: 0.35rem 0.6rem; text-align: left; }
14
- h1, h2, h3 { line-height: 1.25; }
15
- pre { overflow-x: auto; }
16
- `,P=`default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:`;function F(e){return[`<!doctype html><html><head>`,`<meta http-equiv="Content-Security-Policy" content="${P}">`,`<style>${N}</style>`,`</head><body>`,e,`</body></html>`].join(``)}function I(e){let t=(0,O.c)(5),n;t[0]===e.bodyHtml?n=t[1]:(n=F(j(e.bodyHtml)),t[0]=e.bodyHtml,t[1]=n);let r;return t[2]!==e.title||t[3]!==n?(r=(0,M.jsx)(`iframe`,{allow:``,className:`min-h-0 flex-1 border-0 bg-white`,referrerPolicy:`no-referrer`,sandbox:``,srcDoc:n,title:e.title}),t[2]=e.title,t[3]=n,t[4]=r):r=t[4],r}var L=16*1024*1024;function R(n){let[r,i]=(0,D.useState)({status:`loading`});return(0,D.useEffect)(()=>{let r=new AbortController;return(async()=>{i({status:`loading`});let a=await s(n.url,r.signal);if(r.signal.aborted)return;let{value:o}=await(await t(()=>import(`./lib-DyhHMOev.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41]))).convertToHtml({arrayBuffer:a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength)});if(!r.signal.aborted){if(o.length>L)throw Error(`This document is too large to preview.`);i({status:`ready`,bodyHtml:o})}})().catch(e=>{r.signal.aborted||i({status:`failed`,message:e instanceof Error?e.message:`This document could not be opened.`})}),()=>r.abort()},[n.url]),r.status===`failed`?(0,M.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:r.message}):r.status===`loading`?(0,M.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,M.jsx)(o,{className:`size-5`})}):(0,M.jsx)(I,{bodyHtml:r.bodyHtml,title:n.fileName})}export{R as DocxPreview,R as default};
17
- //# sourceMappingURL=DocxPreview-BFCC5VXn.js.map
@@ -1,2 +0,0 @@
1
- import{Bo as e,un as t,wo as n}from"./utils-D0kLIGeh.js";import{cn as r}from"./session-DIGL5_Nm.js";import{a as i,n as a}from"./assetUrls-BBFxUocf.js";import{t as o}from"./spinner-CwxxMzkd.js";var s=n(),c=e();function l(e){let n=(0,s.c)(15),l;n[0]!==e.filePath||n[1]!==e.projectId||n[2]!==e.threadRef.threadId?(l=e.projectId?{_tag:`project-design-preview`,projectId:e.projectId,path:e.filePath}:{_tag:`design-preview`,threadId:e.threadRef.threadId,path:e.filePath},n[0]=e.filePath,n[1]=e.projectId,n[2]=e.threadRef.threadId,n[3]=l):l=n[3];let u=l,d=a(e.threadRef.environmentId,u),f;n[4]!==e.threadRef.environmentId||n[5]!==u?(f=i.createUrl({environmentId:e.threadRef.environmentId,input:{resource:u}}),n[4]=e.threadRef.environmentId,n[5]=u,n[6]=f):f=n[6];let p=r(f);if(d._tag===`Failure`){let e;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,c.jsx)(`p`,{children:`Couldn’t load this preview.`}),n[7]=e):e=n[7];let r;return n[8]===p?r=n[9]:(r=(0,c.jsxs)(`div`,{role:`alert`,className:`flex flex-1 flex-col items-center justify-center gap-3 p-6 text-sm text-muted-foreground`,children:[e,(0,c.jsx)(t,{size:`sm`,variant:`outline`,onClick:()=>p(),children:`Retry`})]}),n[8]=p,n[9]=r),r}if(d._tag!==`Success`){let e;return n[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,c.jsx)(`div`,{className:`grid flex-1 place-items-center text-muted-foreground`,children:(0,c.jsx)(o,{className:`size-5`})}),n[10]=e):e=n[10],e}let m;return n[11]!==d.url||n[12]!==e.fileName||n[13]!==e.version?(m=(0,c.jsx)(`iframe`,{src:d.url,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,title:e.fileName,className:`min-h-0 w-full flex-1 border-0 bg-white`},e.version),n[11]=d.url,n[12]=e.fileName,n[13]=e.version,n[14]=m):m=n[14],m}export{l as HtmlPreview,l as default};
2
- //# sourceMappingURL=HtmlPreview-BpBdu9_j.js.map
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-C_AIVI51.js","assets/index-BKWzfr1Y.js","assets/index-DZprGaeP.css"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./index-BKWzfr1Y.js";import{a as n}from"./useLocalStorage-2W_I13tQ.js";import{Bo as r,xo as i}from"./utils-D0kLIGeh.js";import{t as a}from"./CaretLeft-CDMA3Uas.js";import{t as o}from"./spinner-CwxxMzkd.js";var s=e(n(),1),c=r(),l=100*1024*1024;function u(e,t){let n=t.getViewport({scale:1.5}),r=window.document.createElement(`canvas`);r.className=`mx-auto max-w-full shadow-sm`,r.height=n.height,r.width=n.width;let i=r.getContext(`2d`);return i?(e.replaceChildren(r),t.render({canvas:r,canvasContext:i,viewport:n}).promise):Promise.resolve()}function d(e){let n=(0,s.useRef)(null),[r,d]=(0,s.useState)({status:`loading`}),[f,p]=(0,s.useState)(1),[m,h]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{let n=new AbortController,r=null;return(async()=>{d({status:`loading`}),p(1);let i=await t(()=>import(`./pdf-C_AIVI51.js`),__vite__mapDeps([0,1,2]));i.GlobalWorkerOptions.workerSrc=new URL(`/assets/pdf.worker-TGcf_-kp.mjs`,``+import.meta.url).toString();let a=await fetch(e.url,{signal:n.signal});if(!a.ok)throw Error(`The server returned ${a.status}.`);let o=Number(a.headers.get(`Content-Length`)??NaN);if(Number.isFinite(o)&&o>l)throw Error(`This PDF is too large to preview.`);let s=await a.arrayBuffer();if(n.signal.aborted)return;if(s.byteLength>l)throw Error(`This PDF is too large to preview.`);let c=i.getDocument({data:new Uint8Array(s)});r=c;let u=await c.promise;n.signal.aborted||d({status:`ready`,pageCount:u.numPages,pdf:u})})().catch(e=>{n.signal.aborted||d({status:`failed`,message:e instanceof Error?e.message:`This PDF could not be opened.`})}),()=>{n.abort(),r?.destroy()}},[e.url]),(0,s.useEffect)(()=>{if(r.status!==`ready`)return;let e=n.current;if(!e)return;let t=!1;return h(!0),r.pdf.getPage(f).then(n=>{if(!t)return u(e,n)}).catch(()=>{t||e.replaceChildren()}).finally(()=>{t||h(!1)}),()=>{t=!0}},[f,r]),r.status===`failed`?(0,c.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:r.message}):r.status===`loading`?(0,c.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,c.jsx)(o,{className:`size-5`})}):(0,c.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col overflow-hidden bg-muted/30`,children:[(0,c.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,c.jsx)(`button`,{"aria-label":`Previous PDF page`,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-40`,disabled:f===1,onClick:()=>p(e=>Math.max(1,e-1)),type:`button`,children:(0,c.jsx)(a,{className:`size-4`})}),(0,c.jsxs)(`span`,{className:`text-xs font-medium text-foreground`,children:[`Page `,f,` of `,r.pageCount]}),(0,c.jsx)(`button`,{"aria-label":`Next PDF page`,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-40`,disabled:f===r.pageCount,onClick:()=>p(e=>Math.min(r.pageCount,e+1)),type:`button`,children:(0,c.jsx)(i,{className:`size-4`})})]}),(0,c.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-auto p-4`,children:[m?(0,c.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center text-muted-foreground`,children:(0,c.jsx)(o,{className:`size-5`})}):null,(0,c.jsx)(`div`,{"aria-label":`${e.fileName} page ${f}`,ref:n,role:`document`})]})]})}export{d as PdfPreview,d as default};
3
- //# sourceMappingURL=PdfPreview-CeECoD5z.js.map
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pptxDocument-CHL8asXA.js","assets/rolldown-runtime-DAXXjFlN.js","assets/main-DFDCV-Ns.js","assets/index-BKWzfr1Y.js","assets/index-DZprGaeP.css","assets/useLocalStorage-2W_I13tQ.js","assets/utils-D0kLIGeh.js","assets/session-DIGL5_Nm.js","assets/queries-x5LGu_Fy.js","assets/textarea-DdNchuIO.js","assets/clientPersistenceStorage-DSC61yLx.js","assets/designOpenFileContext-CCQs4ovB.js","assets/empty-DynqTxIR.js","assets/input-Q4KA45-f.js","assets/browserRecording-DrMz1iOt.js","assets/RightPanelResizeHandle-DZdzK7y3.js","assets/browserHistoryStore-K9gWOOUq.js","assets/entities-dwE_i4XM.js","assets/env-DgM3kOA4.js","assets/ArrowRight-BOicMyF9.js","assets/ArrowSquareOut-D7Y2Tt3L.js","assets/scroll-area-D8MfzXjN.js","assets/lib-BpnzBIoA.js","assets/ArrowsClockwise-DycxhEkt.js","assets/ChatMarkdown-Cl8M9HCx.js","assets/assetUrls-BBFxUocf.js","assets/lib-CCiVGdun.js","assets/designCanvas.logic-DuuhotDy.js","assets/designCanvas-CfWhq9nr.css","assets/CaretLeft-CDMA3Uas.js","assets/toggle-CmeCFqd7.js","assets/PullRequestReactions-BWjOU4KY.js","assets/popover-CXGEm4M0.js","assets/composerMentionDrag-D06cCeGC.js","assets/combobox-C4C8XR-w.js","assets/useWorkspaceMutationRefresh-YuIxWftk.js","assets/DiffWorkerPoolProvider-_R9JGgmp.js","assets/toggle-group-iEMUfMdW.js","assets/projectFilesQueryState-7mFyaRdj.js","assets/spinner-CwxxMzkd.js","assets/zipGuard-BHHl8sLU.js","assets/main-CI0aXqkB.css"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./index-BKWzfr1Y.js";import{a as n}from"./useLocalStorage-2W_I13tQ.js";import{Bo as r,xo as i}from"./utils-D0kLIGeh.js";import{t as a}from"./CaretLeft-CDMA3Uas.js";import{t as o}from"./spinner-CwxxMzkd.js";import{t as s}from"./documentBytes-CS3KpytE.js";var c=e(n(),1),l=r();function u(e){let[n,r]=(0,c.useState)({status:`loading`}),[u,d]=(0,c.useState)(0);if((0,c.useEffect)(()=>{let n=new AbortController;return(async()=>{r({status:`loading`}),d(0);let i=await s(e.url,n.signal);if(n.signal.aborted)return;let{readSlides:a}=await t(async()=>{let{readSlides:e}=await import(`./pptxDocument-CHL8asXA.js`);return{readSlides:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41])),o=await a(i);if(!n.signal.aborted){if(o.length===0)throw Error(`This presentation has no readable slides.`);r({status:`ready`,slides:o})}})().catch(e=>{n.signal.aborted||r({status:`failed`,message:e instanceof Error?e.message:`This presentation could not be opened.`})}),()=>n.abort()},[e.url]),n.status===`failed`)return(0,l.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-xs leading-relaxed text-destructive`,children:n.message});if(n.status===`loading`)return(0,l.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,l.jsx)(o,{className:`size-5`})});let f=n.slides[u];return f?(0,l.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,l.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-2`,children:[(0,l.jsx)(`button`,{"aria-label":`Previous slide`,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-40`,disabled:u===0,onClick:()=>d(e=>Math.max(0,e-1)),type:`button`,children:(0,l.jsx)(a,{className:`size-4`})}),(0,l.jsxs)(`span`,{className:`text-xs font-medium text-foreground`,children:[`Slide `,u+1,` of `,n.slides.length]}),(0,l.jsx)(`button`,{"aria-label":`Next slide`,className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-40`,disabled:u===n.slides.length-1,onClick:()=>d(e=>Math.min(n.slides.length-1,e+1)),type:`button`,children:(0,l.jsx)(i,{className:`size-4`})})]}),(0,l.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:(0,l.jsxs)(`article`,{className:`mx-auto max-w-3xl rounded-lg border border-border/60 bg-card p-4`,children:[f.paragraphs.length===0&&f.images.length===0?(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`This slide has no text.`}):null,f.paragraphs.map(e=>(0,l.jsx)(`p`,{className:`mb-1 text-sm leading-relaxed`,children:e},`${f.slideNumber}:${e}`)),f.images.length>0?(0,l.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:f.images.map(e=>(0,l.jsx)(`img`,{alt:``,className:`max-h-40 max-w-full rounded border border-border/60`,src:e},e.slice(0,64)))}):null,f.notes===``?null:(0,l.jsxs)(`details`,{className:`mt-3`,children:[(0,l.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground`,children:`Speaker notes`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed whitespace-pre-line text-muted-foreground`,children:f.notes})]})]})})]}):null}export{u as PptxPreview,u as default};
3
- //# sourceMappingURL=PptxPreview-u6gN3x3Z.js.map
@@ -1,2 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{Ha as t,Ra as n,a as r,st as i}from"./useLocalStorage-2W_I13tQ.js";import{Bn as a,Bo as o,Co as s,Fn as c,In as l,Mn as u,N as d,Nn as f,On as p,Pn as m,Rn as h,Vn as g,do as _,ho as v,t as y,un as b,wo as x,zn as S}from"./utils-D0kLIGeh.js";import{gn as C,hn as w,pn as T,qt as E,un as D,vn as O,wn as k}from"./session-DIGL5_Nm.js";import{Ln as A,N as ee,c as j,f as M,l as N,nr as P,o as F,u as te,ur as I,w as ne,z as re}from"./textarea-DdNchuIO.js";import{a as L,c as R,l as ie,o as z,r as B,s as ae,t as V,u as H}from"./empty-DynqTxIR.js";import{$ as oe,B as U,E as se,H as W,J as G,K as ce,Q as K,U as q,V as J,X as le,Y,Z as ue,a as de,c as X,d as fe,et as pe,g as me,h as he,i as ge,j as _e,k as ve,n as ye,o as be,p as xe,q as Se,s as Ce,t as we,v as Te,x as Ee,y as De}from"./browserRecording-DrMz1iOt.js";import{t as Oe}from"./ArrowRight-BOicMyF9.js";import{t as ke}from"./ArrowSquareOut-D7Y2Tt3L.js";import{i as Ae,r as je}from"./RightPanelResizeHandle-DZdzK7y3.js";import{A as Me,D as Ne,E as Pe,M as Fe,N as Ie,P as Le,T as Re,b as ze,d as Be,f as Ve,h as He,i as Ue,m as We,n as Ge,o as Ke,r as qe,t as Je,v as Ye,w as Xe}from"./browserHistoryStore-K9gWOOUq.js";import{j as Ze}from"./entities-dwE_i4XM.js";import{s as Qe}from"./env-DgM3kOA4.js";var Z=e(r(),1),$e=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M208,52H182.42L170,33.34A12,12,0,0,0,160,28H96a12,12,0,0,0-10,5.34L73.57,52H48A28,28,0,0,0,20,80V192a28,28,0,0,0,28,28H208a28,28,0,0,0,28-28V80A28,28,0,0,0,208,52Zm4,140a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V80a4,4,0,0,1,4-4H80a12,12,0,0,0,10-5.34L102.42,52h51.15L166,70.66A12,12,0,0,0,176,76h32a4,4,0,0,1,4,4ZM128,84a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,84Zm0,72a24,24,0,1,1,24-24A24,24,0,0,1,128,156Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M208,64H176L160,40H96L80,64H48A16,16,0,0,0,32,80V192a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V80A16,16,0,0,0,208,64ZM128,168a36,36,0,1,1,36-36A36,36,0,0,1,128,168Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M208,56H180.28L166.65,35.56A8,8,0,0,0,160,32H96a8,8,0,0,0-6.65,3.56L75.71,56H48A24,24,0,0,0,24,80V192a24,24,0,0,0,24,24H208a24,24,0,0,0,24-24V80A24,24,0,0,0,208,56Zm8,136a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V80a8,8,0,0,1,8-8H80a8,8,0,0,0,6.66-3.56L100.28,48h55.43l13.63,20.44A8,8,0,0,0,176,72h32a8,8,0,0,1,8,8ZM128,88a44,44,0,1,0,44,44A44.05,44.05,0,0,0,128,88Zm0,72a28,28,0,1,1,28-28A28,28,0,0,1,128,160Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M208,56H180.28L166.65,35.56A8,8,0,0,0,160,32H96a8,8,0,0,0-6.65,3.56L75.71,56H48A24,24,0,0,0,24,80V192a24,24,0,0,0,24,24H208a24,24,0,0,0,24-24V80A24,24,0,0,0,208,56Zm-44,76a36,36,0,1,1-36-36A36,36,0,0,1,164,132Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M208,58H179.21L165,36.67A6,6,0,0,0,160,34H96a6,6,0,0,0-5,2.67L76.78,58H48A22,22,0,0,0,26,80V192a22,22,0,0,0,22,22H208a22,22,0,0,0,22-22V80A22,22,0,0,0,208,58Zm10,134a10,10,0,0,1-10,10H48a10,10,0,0,1-10-10V80A10,10,0,0,1,48,70H80a6,6,0,0,0,5-2.67L99.21,46h57.57L171,67.33A6,6,0,0,0,176,70h32a10,10,0,0,1,10,10ZM128,90a42,42,0,1,0,42,42A42,42,0,0,0,128,90Zm0,72a30,30,0,1,1,30-30A30,30,0,0,1,128,162Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M208,56H180.28L166.65,35.56A8,8,0,0,0,160,32H96a8,8,0,0,0-6.65,3.56L75.71,56H48A24,24,0,0,0,24,80V192a24,24,0,0,0,24,24H208a24,24,0,0,0,24-24V80A24,24,0,0,0,208,56Zm8,136a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V80a8,8,0,0,1,8-8H80a8,8,0,0,0,6.66-3.56L100.28,48h55.43l13.63,20.44A8,8,0,0,0,176,72h32a8,8,0,0,1,8,8ZM128,88a44,44,0,1,0,44,44A44.05,44.05,0,0,0,128,88Zm0,72a28,28,0,1,1,28-28A28,28,0,0,1,128,160Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M208,60H178.13L163.32,37.78A4,4,0,0,0,160,36H96a4,4,0,0,0-3.32,1.78L77.85,60H48A20,20,0,0,0,28,80V192a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V80A20,20,0,0,0,208,60Zm12,132a12,12,0,0,1-12,12H48a12,12,0,0,1-12-12V80A12,12,0,0,1,48,68H80a4,4,0,0,0,3.33-1.78L98.13,44h59.72l14.82,22.22A4,4,0,0,0,176,68h32a12,12,0,0,1,12,12ZM128,92a40,40,0,1,0,40,40A40,40,0,0,0,128,92Zm0,72a32,32,0,1,1,32-32A32,32,0,0,1,128,164Z`}))]]),et=new Map([[`bold`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M112,60a16,16,0,1,1,16,16A16,16,0,0,1,112,60Zm16,52a16,16,0,1,0,16,16A16,16,0,0,0,128,112Zm0,68a16,16,0,1,0,16,16A16,16,0,0,0,128,180Z`}))],[`duotone`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M176,32V224a16,16,0,0,1-16,16H96a16,16,0,0,1-16-16V32A16,16,0,0,1,96,16h64A16,16,0,0,1,176,32Z`,opacity:`0.2`}),Z.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM128,72a12,12,0,1,0-12-12A12,12,0,0,0,128,72Zm0,112a12,12,0,1,0,12,12A12,12,0,0,0,128,184Z`}))],[`fill`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M160,16H96A16,16,0,0,0,80,32V224a16,16,0,0,0,16,16h64a16,16,0,0,0,16-16V32A16,16,0,0,0,160,16ZM128,208a12,12,0,1,1,12-12A12,12,0,0,1,128,208Zm0-68a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm0-68a12,12,0,1,1,12-12A12,12,0,0,1,128,72Z`}))],[`light`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M118,60a10,10,0,1,1,10,10A10,10,0,0,1,118,60Zm10,58a10,10,0,1,0,10,10A10,10,0,0,0,128,118Zm0,68a10,10,0,1,0,10,10A10,10,0,0,0,128,186Z`}))],[`regular`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM128,72a12,12,0,1,0-12-12A12,12,0,0,0,128,72Zm0,112a12,12,0,1,0,12,12A12,12,0,0,0,128,184Z`}))],[`thin`,Z.createElement(Z.Fragment,null,Z.createElement(`path`,{d:`M120,60a8,8,0,1,1,8,8A8,8,0,0,1,120,60Zm8,60a8,8,0,1,0,8,8A8,8,0,0,0,128,120Zm0,68a8,8,0,1,0,8,8A8,8,0,0,0,128,188Z`}))]]),tt=Object.defineProperty,nt=Object.defineProperties,rt=Object.getOwnPropertyDescriptors,it=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable,st=(e,t,n)=>t in e?tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ct=(e,t)=>{for(var n in t||={})at.call(t,n)&&st(e,n,t[n]);if(it)for(var n of it(t))ot.call(t,n)&&st(e,n,t[n]);return e},lt=(e,t)=>nt(e,rt(t)),ut=(0,Z.forwardRef)((e,t)=>Z.createElement(s,lt(ct({ref:t},e),{weights:$e})));ut.displayName=`Camera`;var dt=Object.defineProperty,ft=Object.defineProperties,pt=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable,_t=(e,t,n)=>t in e?dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vt=(e,t)=>{for(var n in t||={})ht.call(t,n)&&_t(e,n,t[n]);if(mt)for(var n of mt(t))gt.call(t,n)&&_t(e,n,t[n]);return e},yt=(e,t)=>ft(e,pt(t)),bt=(0,Z.forwardRef)((e,t)=>Z.createElement(s,yt(vt({ref:t},e),{weights:et})));bt.displayName=`DotsThreeVertical`;var Q=x(),$=o(),xt=()=>{};function St(e){let t=(0,Q.c)(92),{url:n,loading:r,canGoBack:i,canGoForward:a,refreshDisabled:o,inputDisabled:s,focusUrlNonce:c,onBack:l,onForward:u,onRefresh:d,onSubmit:f,onOpenInBrowser:p,onCapture:m,captureDisabled:h,recording:g,onPictureInPicture:_,pictureInPicture:v,pictureInPictureDisabled:x,onPickElement:S,pickActive:C,pickDisabled:w,pickDisabledReason:T,trailingActions:E}=e,D=(0,Z.useRef)(null),[O,k]=(0,Z.useState)(n),[A,ee]=(0,Z.useState)(!1),j,P;t[0]===c?(j=t[1],P=t[2]):(j=()=>{if(c==null)return;let e=D.current;e&&e.focus()},P=[c],t[0]=c,t[1]=j,t[2]=P),(0,Z.useEffect)(j,P);let F;t[3]!==O||t[4]!==f?(F=e=>{e?.preventDefault();let t=O.trim();t.length!==0&&(f(t),D.current?.blur())},t[3]=O,t[4]=f,t[5]=F):F=t[5];let I=F,ne=i?l:xt,re=!i,L;t[6]!==ne||t[7]!==re?(L=(0,$.jsx)(b,{variant:`ghost`,size:`icon-xs`,onClick:ne,disabled:re,"aria-label":`Back`,type:`button`}),t[6]=ne,t[7]=re,t[8]=L):L=t[8];let z;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(oe,{}),t[9]=z):z=t[9];let B;t[10]===L?B=t[11]:(B=(0,$.jsx)(M,{render:L,children:z}),t[10]=L,t[11]=B);let V;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(te,{children:`Back`}),t[12]=V):V=t[12];let U;t[13]===B?U=t[14]:(U=(0,$.jsxs)(N,{children:[B,V]}),t[13]=B,t[14]=U);let se=a?u:xt,W=!a,G;t[15]!==se||t[16]!==W?(G=(0,$.jsx)(b,{variant:`ghost`,size:`icon-xs`,onClick:se,disabled:W,"aria-label":`Forward`,type:`button`}),t[15]=se,t[16]=W,t[17]=G):G=t[17];let ce;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(Oe,{}),t[18]=ce):ce=t[18];let K;t[19]===G?K=t[20]:(K=(0,$.jsx)(M,{render:G,children:ce}),t[19]=G,t[20]=K);let q;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(te,{children:`Forward`}),t[21]=q):q=t[21];let J;t[22]===K?J=t[23]:(J=(0,$.jsxs)(N,{children:[K,q]}),t[22]=K,t[23]=J);let le=o?xt:d,de=r?`Stop`:`Refresh`,X;t[24]!==o||t[25]!==le||t[26]!==de?(X=(0,$.jsx)(b,{variant:`ghost`,size:`icon-xs`,onClick:le,disabled:o,"aria-label":de,type:`button`}),t[24]=o,t[25]=le,t[26]=de,t[27]=X):X=t[27];let fe=r&&`animate-spin`,pe;t[28]===fe?pe=t[29]:(pe=y(fe),t[28]=fe,t[29]=pe);let me;t[30]===pe?me=t[31]:(me=(0,$.jsx)(H,{className:pe}),t[30]=pe,t[31]=me);let he;t[32]!==X||t[33]!==me?(he=(0,$.jsx)(M,{render:X,children:me}),t[32]=X,t[33]=me,t[34]=he):he=t[34];let ge=r?`Loading…`:`Refresh`,_e;t[35]===ge?_e=t[36]:(_e=(0,$.jsx)(te,{children:ge}),t[35]=ge,t[36]=_e);let ve;t[37]!==he||t[38]!==_e?(ve=(0,$.jsxs)(N,{children:[he,_e]}),t[37]=he,t[38]=_e,t[39]=ve):ve=t[39];let ye;t[40]!==U||t[41]!==J||t[42]!==ve?(ye=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[U,J,ve]}),t[40]=U,t[41]=J,t[42]=ve,t[43]=ye):ye=t[43];let be=A?O:n,xe=p&&!A&&`group-hover/address:pe-7 transition-[padding]`,Se;t[44]===xe?Se=t[45]:(Se=y(xe),t[44]=xe,t[45]=Se);let Ce;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=e=>k(e.target.value),t[46]=Ce):Ce=t[46];let we;t[47]===n?we=t[48]:(we=()=>{k(n),ee(!0),queueMicrotask(()=>D.current?.select())},t[47]=n,t[48]=we);let Te;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(Te=()=>{ee(!1)},t[49]=Te):Te=t[49];let Ee;t[50]!==I||t[51]!==n?(Ee=e=>{e.key===`Enter`&&I(e),e.key===`Escape`&&(e.preventDefault(),k(n),D.current?.blur())},t[50]=I,t[51]=n,t[52]=Ee):Ee=t[52];let De;t[53]!==s||t[54]!==be||t[55]!==Se||t[56]!==we||t[57]!==Ee?(De=(0,$.jsx)(N,{children:(0,$.jsx)(M,{render:(0,$.jsx)(ie,{ref:D,value:be,className:Se,onChange:Ce,onFocus:we,onBlur:Te,onKeyDown:Ee,placeholder:`Search or enter URL`,spellCheck:!1,disabled:s,"data-preview-url-input":!0,size:`sm`})})}),t[53]=s,t[54]=be,t[55]=Se,t[56]=we,t[57]=Ee,t[58]=De):De=t[58];let Ae;t[59]!==A||t[60]!==p?(Ae=p&&!A?(0,$.jsx)(R,{align:`inline-end`,className:`pointer-events-none absolute inset-y-0 right-0 opacity-0 transition-opacity group-hover/address:pointer-events-auto group-hover/address:opacity-100`,children:(0,$.jsxs)(N,{children:[(0,$.jsx)(M,{render:(0,$.jsx)(b,{variant:`ghost`,size:`icon-xs`,onClick:p,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(ke,{})}),(0,$.jsx)(te,{children:`Open in system browser`})]})}):null,t[59]=A,t[60]=p,t[61]=Ae):Ae=t[61];let je;t[62]!==De||t[63]!==Ae?(je=(0,$.jsxs)(ae,{variant:`ghost`,className:`group/address h-7 flex-1`,children:[De,Ae]}),t[62]=De,t[63]=Ae,t[64]=je):je=t[64];let Me;t[65]!==S||t[66]!==C||t[67]!==w||t[68]!==T?(Me=S?(0,$.jsxs)(N,{children:[(0,$.jsx)(M,{render:(0,$.jsx)(b,{variant:C?`secondary`:`ghost`,size:`icon-xs`,onClick:S,disabled:w,"aria-label":C?`Cancel annotation`:`Annotate preview`,"aria-pressed":C?`true`:`false`,type:`button`}),children:(0,$.jsx)(ue,{className:y(C&&`text-primary`)})}),(0,$.jsx)(te,{children:w&&T?T:C?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[65]=S,t[66]=C,t[67]=w,t[68]=T,t[69]=Me):Me=t[69];let Ne;t[70]!==h||t[71]!==m||t[72]!==g?(Ne=m?(0,$.jsxs)(N,{children:[(0,$.jsxs)(M,{render:(0,$.jsx)(b,{variant:g?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>m(e.shiftKey),"aria-label":g?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:h}),children:[(0,$.jsx)(ut,{className:y(g&&`text-destructive`)}),g?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(te,{children:g?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[70]=h,t[71]=m,t[72]=g,t[73]=Ne):Ne=t[73];let Pe;t[74]!==_||t[75]!==v||t[76]!==x?(Pe=_?(0,$.jsxs)(N,{children:[(0,$.jsx)(M,{render:(0,$.jsx)(b,{variant:v?`secondary`:`ghost`,size:`icon-xs`,onClick:_,"aria-label":v?`Close floating preview`:`Float preview over chat`,"aria-pressed":v?`true`:`false`,type:`button`,disabled:x}),children:(0,$.jsx)(Y,{className:y(v&&`text-primary`)})}),(0,$.jsx)(te,{children:v?`Close floating preview`:`Float preview over chat`})]}):null,t[74]=_,t[75]=v,t[76]=x,t[77]=Pe):Pe=t[77];let Fe;t[78]!==I||t[79]!==ye||t[80]!==je||t[81]!==Me||t[82]!==Ne||t[83]!==Pe||t[84]!==E?(Fe=(0,$.jsxs)(`form`,{onSubmit:I,className:`flex h-10 min-h-10 shrink-0 items-center gap-1 border-b border-border/60 bg-background px-2 in-data-[preview-panel-mode=inline]:mb-3 in-data-[preview-panel-mode=inline]:h-7 in-data-[preview-panel-mode=inline]:min-h-7 in-data-[preview-panel-mode=inline]:border-b-transparent`,"data-surface-subheader":!0,children:[ye,je,Me,Ne,Pe,E]}),t[78]=I,t[79]=ye,t[80]=je,t[81]=Me,t[82]=Ne,t[83]=Pe,t[84]=E,t[85]=Fe):Fe=t[85];let Ie;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(Ie={boxShadow:`0 0 6px 1px var(--color-ring)`},t[86]=Ie):Ie=t[86];let Le;t[87]===r?Le=t[88]:(Le=(0,$.jsx)(`div`,{"aria-hidden":!0,"data-loading":r,className:`preview-loading-progress pointer-events-none absolute bottom-0 left-0 z-10 h-0.5 w-full origin-left rounded-r-full bg-primary`,style:Ie}),t[87]=r,t[88]=Le);let Re;return t[89]!==Fe||t[90]!==Le?(Re=(0,$.jsxs)(`div`,{className:`relative`,children:[Fe,Le]}),t[89]=Fe,t[90]=Le,t[91]=Re):Re=t[91],Re}function Ct(e){let t=(0,Q.c)(17),{threadRef:n,server:r,onOpen:i}=e,a;t[0]===r?a=t[1]:(a=wt(r),t[0]=r,t[1]=a);let o=a,s;t[2]!==r.requestedUrl||t[3]!==n?(s=(0,$.jsx)(Ee,{threadRef:n,url:r.requestedUrl}),t[2]=r.requestedUrl,t[3]=n,t[4]=s):s=t[4];let c;t[5]===o?c=t[6]:(c=(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:o}),t[5]=o,t[6]=c);let l;t[7]!==r.host||t[8]!==r.port?(l=(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[r.host,`:`,r.port]}),t[7]=r.host,t[8]=r.port,t[9]=l):l=t[9];let u;t[10]!==c||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;return t[13]!==i||t[14]!==s||t[15]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`group flex w-full items-center gap-3 px-3 py-3 text-left hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[s,u]}),t[13]=i,t[14]=s,t[15]=u,t[16]=d):d=t[16],d}function wt(e){return e.processName?e.processName:`Listening`}function Tt(e){let t=(0,Q.c)(26),{threadRef:n,entry:r,onOpen:i,onRemove:a}=e,o;t[0]===r.url?o=t[1]:(o=new URL(r.url),t[0]=r.url,t[1]=o);let s=o,c=s.pathname===`/`?``:s.pathname,l=`${s.host}${c}${s.search}${s.hash}`,u;t[2]===r.lastVisitedAt?u=t[3]:(u=Je(r.lastVisitedAt)?Qe(new Date(r.lastVisitedAt).toISOString()):``,t[2]=r.lastVisitedAt,t[3]=u);let d=u;De();let f;t[4]!==r.url||t[5]!==n?(f=(0,$.jsx)(Ee,{threadRef:n,url:r.url}),t[4]=r.url,t[5]=n,t[6]=f):f=t[6];let p=r.title??l,m;t[7]===p?m=t[8]:(m=(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:p}),t[7]=p,t[8]=m);let h=r.title?`${l} · `:``,g;t[9]!==h||t[10]!==d?(g=(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[h,d]}),t[9]=h,t[10]=d,t[11]=g):g=t[11];let _;t[12]!==m||t[13]!==g?(_=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[m,g]}),t[12]=m,t[13]=g,t[14]=_):_=t[14];let v;t[15]!==i||t[16]!==f||t[17]!==_?(v=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex w-full items-center gap-3 px-3 py-3 pr-10 text-left hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[f,_]}),t[15]=i,t[16]=f,t[17]=_,t[18]=v):v=t[18];let y=`Remove ${l} from history`,b;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(I,{className:`size-3.5`}),t[19]=b):b=t[19];let x;t[20]!==a||t[21]!==y?(x=(0,$.jsx)(`button`,{type:`button`,"aria-label":y,onClick:a,className:`absolute right-3 rounded p-1 text-muted-foreground opacity-0 hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover:opacity-100`,children:b}),t[20]=a,t[21]=y,t[22]=x):x=t[22];let S;return t[23]!==x||t[24]!==v?(S=(0,$.jsxs)(`div`,{className:`group relative flex w-full items-center`,children:[v,x]}),t[23]=x,t[24]=v,t[25]=S):S=t[25],S}var Et=Object.freeze([]);function Dt(e){let t=[],n=new Set;for(let r of e??[])if(!(r.length===0||r.length>2048||r.trim().length!==r.length))try{let e=new URL(r);if(e.protocol!==`http:`&&e.protocol!==`https:`||!Ve(e.hostname)||e.href.length>2048)continue;let i=new URL(e.href);if(i.hash=``,n.has(i.href))continue;if(n.add(i.href),t.push(e.href),t.length>=32)break}catch{}return t}function Ot(e,t){let n=(0,Q.c)(7),r,i;if(n[0]!==t||n[1]!==e){let a=Dt(t);r=A,i=e===null?null:Ye.discoveredServers({environmentId:e,input:a.length?{configuredUrls:a}:{}}),n[0]=t,n[1]=e,n[2]=r,n[3]=i}else r=n[2],i=n[3];let a=r(i);a.data?.configuredUrlProbing,a.data?.servers;let o=a.data?.servers??Et,s=a.data?.configuredUrlProbing===!0,c;return n[4]!==o||n[5]!==s?(c={servers:o,configuredUrlProbing:s},n[4]=o,n[5]=s,n[6]=c):c=n[6],c}function kt(e){let t=(0,Q.c)(7),n=Ot(e.environmentId,e.configuredUrls),r;if(t[0]!==e.configuredUrls||t[1]!==e.environmentId||t[2]!==n.configuredUrlProbing||t[3]!==n.servers){let i;t[5]===e.environmentId?i=t[6]:(i=t=>({...t,url:Be(e.environmentId,t.url),requestedUrl:t.url}),t[5]=e.environmentId,t[6]=i),r=At({scanner:n.servers.map(i),configuredUrls:e.configuredUrls??[],configuredUrlProbing:n.configuredUrlProbing}),t[0]=e.configuredUrls,t[1]=e.environmentId,t[2]=n.configuredUrlProbing,t[3]=n.servers,t[4]=r}else r=t[4];return r}function At(e){let t=new Map;for(let n of e.configuredUrls){let e=Mt(n);if(!e)continue;let r=jt(e.host,e.port);t.has(r)||t.set(r,e)}let n=[];for(let r of e.scanner){let i=jt(r.host,r.port),a=t.get(i);n.push({...r,requestedUrl:a&&e.configuredUrlProbing===!1?a.url:r.requestedUrl,source:a?`configured`:`scanner`})}return n.toSorted((e,t)=>{let n={configured:0,scanner:1};return n[e.source]===n[t.source]?e.port-t.port:n[e.source]-n[t.source]})}function jt(e,t){let n=e.toLowerCase();return`${Ve(n)?`loopback`:n}:${t}`}function Mt(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!Ve(t.hostname))return null;let n=t.port?Number.parseInt(t.port,10):t.protocol===`http:`?80:443;return!Number.isFinite(n)||n<=0?null:{host:t.hostname,port:n,url:t.href}}catch{return null}}function Nt(e){let t=(0,Q.c)(24),{threadRef:n,environmentId:r,configuredUrls:i,recentEntries:a,onRemoveRecent:o,onOpenUrl:s}=e,c;t[0]!==i||t[1]!==r?(c={environmentId:r,configuredUrls:i},t[0]=i,t[1]=r,t[2]=c):c=t[2];let l=kt(c),u,d,f,p;if(t[3]!==s||t[4]!==o||t[5]!==a||t[6]!==l.length||t[7]!==n){p=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a.filter(Pt).slice(0,8);if(l.length===0&&e.length===0){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(V,{children:[(0,$.jsx)(L,{variant:`icon`,children:(0,$.jsx)(Le,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(z,{children:`No preview yet`}),(0,$.jsx)(B,{children:`Type a URL above, or run a dev script. Browser-ready localhost servers will show up here automatically.`})]}),t[12]=e):e=t[12],p=e;break bb0}f=`flex h-full min-h-0 overflow-y-auto px-5 py-8`,u=`mx-auto flex w-full max-w-xl flex-col gap-6`,d=e.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(Ae,{className:`size-4 shrink-0`}),(0,$.jsx)(`h2`,{className:`font-medium`,children:`Recently used`})]}),(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-line overflow-hidden rounded-tile bg-canvas-quiet`,children:e.map(e=>(0,$.jsx)(Tt,{threadRef:n,entry:e,onOpen:()=>s(e.url),onRemove:()=>o(e.url)},e.url))})]}):null}t[3]=s,t[4]=o,t[5]=a,t[6]=l.length,t[7]=n,t[8]=u,t[9]=d,t[10]=f,t[11]=p}else u=t[8],d=t[9],f=t[10],p=t[11];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let m;t[13]!==s||t[14]!==l||t[15]!==n?(m=l.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(K,{className:`size-4 shrink-0`}),(0,$.jsx)(`h2`,{className:`font-medium`,children:`Local servers`})]}),(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-line overflow-hidden rounded-tile bg-canvas-quiet`,children:l.map(e=>(0,$.jsx)(Ct,{threadRef:n,server:e,onOpen:()=>s(e.requestedUrl)},`${e.host}:${e.port}`))}),(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:`Select a live local server to open it in this browser tab.`})]}):null,t[13]=s,t[14]=l,t[15]=n,t[16]=m):m=t[16];let h;t[17]!==u||t[18]!==d||t[19]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[d,m]}),t[17]=u,t[18]=d,t[19]=m,t[20]=h):h=t[20];let g;return t[21]!==f||t[22]!==h?(g=(0,$.jsx)(`div`,{className:f,children:h}),t[21]=f,t[22]=h,t[23]=g):g=t[23],g}function Pt(e){return URL.canParse(e.url)}var Ft=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function It(e){let t=(0,Q.c)(73),{tabId:n,hasWebContents:r,zoomFactor:i,colorScheme:o,deviceToolbarVisible:s,onToggleDeviceToolbar:c,nativePictureInPicture:d,onNativePictureInPicture:_}=e,v=ne();if(!J)return null;let y=!n||!r,x;t[0]===n?x=t[1]:(x=e=>()=>{n&&e(n).catch(Wt)},t[0]=n,t[1]=x);let C=x,w;t[2]===i?w=t[3]:(w=Math.round(i*100),t[2]=i,t[3]=w);let T=`${w}%`,E;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsxs)(N,{children:[(0,$.jsx)(M,{render:(0,$.jsx)(g,{render:(0,$.jsx)(b,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(bt,{})}),(0,$.jsx)(te,{children:`More`})]}),t[4]=E):E=t[4];let D;t[5]===C?D=t[6]:(D=C(J.hardReload),t[5]=C,t[6]=D);let O;t[7]!==D||t[8]!==y?(O=(0,$.jsx)(u,{onClick:D,disabled:y,children:`Hard reload`}),t[7]=D,t[8]=y,t[9]=O):O=t[9];let k;t[10]!==C||t[11]!==v||t[12]!==y?(k=v?(0,$.jsx)(u,{onClick:C(J.openDevTools),disabled:y,children:`Open DevTools`}):null,t[10]=C,t[11]=v,t[12]=y,t[13]=k):k=t[13];let A=d?`Close separate preview window`:`Open separate preview window`,ee;t[14]!==_||t[15]!==A||t[16]!==y?(ee=(0,$.jsx)(u,{onClick:_,disabled:y,children:A}),t[14]=_,t[15]=A,t[16]=y,t[17]=ee):ee=t[17];let j=s?`Hide device toolbar`:`Show device toolbar`,P;t[18]!==c||t[19]!==j||t[20]!==y?(P=(0,$.jsx)(u,{onClick:c,disabled:y,children:j}),t[18]=c,t[19]=j,t[20]=y,t[21]=P):P=t[21];let F;t[22]===y?F=t[23]:(F=(0,$.jsx)(a,{disabled:y,children:`Appearance`}),t[22]=y,t[23]=F);let I;t[24]===n?I=t[25]:(I=e=>{n&&J.setColorScheme(n,e).catch(Ut)},t[24]=n,t[25]=I);let re;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(re=Ft.map(Ht),t[26]=re):re=t[26];let L;t[27]!==o||t[28]!==I?(L=(0,$.jsx)(S,{className:`min-w-32`,children:(0,$.jsx)(m,{value:o,onValueChange:I,children:re})}),t[27]=o,t[28]=I,t[29]=L):L=t[29];let R;t[30]!==F||t[31]!==L?(R=(0,$.jsxs)(h,{children:[F,L]}),t[30]=F,t[31]=L,t[32]=R):R=t[32];let ie;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(l,{}),t[33]=ie):ie=t[33];let z;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(`span`,{children:`Zoom`}),t[34]=z):z=t[34];let B;t[35]===C?B=t[36]:(B=C(J.zoomOut),t[35]=C,t[36]=B);let ae;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(le,{}),t[37]=ae):ae=t[37];let V;t[38]!==B||t[39]!==y?(V=(0,$.jsx)(b,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:B,"aria-label":`Zoom out`,disabled:y,children:ae}),t[38]=B,t[39]=y,t[40]=V):V=t[40];let H;t[41]===T?H=t[42]:(H=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:T}),t[41]=T,t[42]=H);let oe;t[43]===C?oe=t[44]:(oe=C(J.zoomIn),t[43]=C,t[44]=oe);let U;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(G,{}),t[45]=U):U=t[45];let se;t[46]!==oe||t[47]!==y?(se=(0,$.jsx)(b,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:oe,"aria-label":`Zoom in`,disabled:y,children:U}),t[46]=oe,t[47]=y,t[48]=se):se=t[48];let W;t[49]===C?W=t[50]:(W=C(J.resetZoom),t[49]=C,t[50]=W);let ce;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(pe,{}),t[51]=ce):ce=t[51];let K;t[52]!==W||t[53]!==y?(K=(0,$.jsx)(b,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:W,"aria-label":`Reset zoom`,className:`[:hover,[data-pressed]]:bg-foreground/10`,disabled:y,children:ce}),t[52]=W,t[53]=y,t[54]=K):K=t[54];let q;t[55]!==V||t[56]!==H||t[57]!==se||t[58]!==K?(q=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[V,H,se,K]}),t[55]=V,t[56]=H,t[57]=se,t[58]=K,t[59]=q):q=t[59];let Y;t[60]!==q||t[61]!==y?(Y=(0,$.jsxs)(u,{closeOnClick:!1,onClick:Vt,className:`justify-between`,disabled:y,children:[z,q]}),t[60]=q,t[61]=y,t[62]=Y):Y=t[62];let ue,de,X;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(l,{}),de=(0,$.jsx)(u,{onClick:zt,children:`Clear cookies`}),X=(0,$.jsx)(u,{onClick:Lt,children:`Clear cache`}),t[63]=ue,t[64]=de,t[65]=X):(ue=t[63],de=t[64],X=t[65]);let fe;return t[66]!==P||t[67]!==R||t[68]!==Y||t[69]!==O||t[70]!==k||t[71]!==ee?(fe=(0,$.jsxs)(p,{children:[E,(0,$.jsxs)(f,{align:`end`,sideOffset:6,className:`min-w-56`,children:[O,k,ee,P,R,ie,Y,ue,de,X]})]}),t[66]=P,t[67]=R,t[68]=Y,t[69]=O,t[70]=k,t[71]=ee,t[72]=fe):fe=t[72],fe}function Lt(){J.clearCache().catch(Rt)}function Rt(){}function zt(){J.clearCookies().catch(Bt)}function Bt(){}function Vt(e){return e.preventDefault()}function Ht(e){return(0,$.jsx)(c,{value:e.value,children:e.label},e.value)}function Ut(){}function Wt(){}function Gt(e){return Ie[e]||(e.length>0?e:`Network error`)}function Kt(e){let t=(0,Q.c)(32),{url:n,code:r,description:i,onReload:a}=e,[o,s]=(0,Z.useState)(!1),c;t[0]===n?c=t[1]:(c=Yt(n)??n,t[0]=n,t[1]=c);let l=c,u;t[2]===i?u=t[3]:(u=Gt(i),t[2]=i,t[3]=u);let d=u,f;t[4]!==r||t[5]!==i?(f=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=f):f=t[6];let p=f,m,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Jt,{className:`mb-6 size-12 text-muted-foreground/70`}),h=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=m,t[8]=h):(m=t[7],h=t[8]);let g;t[9]===l?g=t[10]:(g=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:l}),t[9]=l,t[10]=g);let _;t[11]!==d||t[12]!==g?(_=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[g,`: `,d,`.`]}),t[11]=d,t[12]=g,t[13]=_):_=t[13];let v;t[14]===o?v=t[15]:(v=o?(0,$.jsxs)(`div`,{className:`mt-6 rounded-lg border border-border bg-muted/40 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`mb-2 font-medium text-foreground`,children:`Try:`}),(0,$.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:[(0,$.jsx)(`li`,{children:`Checking your connection`}),(0,$.jsx)(`li`,{children:`Confirming the dev server is running`}),(0,$.jsx)(`li`,{children:`Checking the proxy and the firewall`})]})]}):null,t[14]=o,t[15]=v);let y;t[16]===p?y=t[17]:(y=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:p}),t[16]=p,t[17]=y);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>s(qt),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(b,{type:`button`,variant:`outline`,size:`sm`,onClick:x,children:S}),t[19]=S,t[20]=C);let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`div`,{className:`flex-1`}),t[21]=w):w=t[21];let T;t[22]===a?T=t[23]:(T=(0,$.jsx)(b,{type:`button`,size:`sm`,onClick:a,children:`Reload`}),t[22]=a,t[23]=T);let E;t[24]!==C||t[25]!==T?(E=(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-8`,children:[C,w,T]}),t[24]=C,t[25]=T,t[26]=E):E=t[26];let D;return t[27]!==E||t[28]!==_||t[29]!==v||t[30]!==y?(D=(0,$.jsx)(`div`,{className:`relative flex h-full min-h-0 w-full overflow-y-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-1 flex-col px-8 py-12 sm:py-16`,children:[m,h,_,v,y,E]})}),t[27]=E,t[28]=_,t[29]=v,t[30]=y,t[31]=D):D=t[31],D}function qt(e){return!e}function Jt(e){let t=(0,Q.c)(5),{className:n}=e,r,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`path`,{d:`M16 12 L48 12 L48 52 L16 52 Z`}),i=(0,$.jsx)(`path`,{d:`M22 22 L42 22 M22 30 L36 30 M22 38 L40 38`,strokeLinecap:`round`}),a=(0,$.jsx)(`path`,{d:`M52 8 L12 56`,strokeLinecap:`round`}),t[0]=r,t[1]=i,t[2]=a):(r=t[0],i=t[1],a=t[2]);let o;return t[3]===n?o=t[4]:(o=(0,$.jsxs)(`svg`,{viewBox:`0 0 64 64`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,className:n,children:[r,i,a]}),t[3]=n,t[4]=o),o}function Yt(e){try{return new URL(e).host}catch{return null}}var Xt=class extends t()(`PreviewSessionThreadKeyParseError`,{threadKey:n}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},Zt=T(e=>{let t=_(e);if(t===null)throw new Xt({threadKey:e});let n=Ye.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=Ye.events({environmentId:t.environmentId,input:{}});return w(e=>{let i=!1,a=0,o=e=>{k(e)&&Pe(t,e.value)},s=r=>{if(!k(r)||r.value.threadId!==t.threadId)return;let i=Re(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}ze(t,r.value)};e.addFinalizer(()=>{i=!0});let c=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,s(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&s(c))})}).pipe(C(1e3),O(`preview:session-sync:${e}`))});function Qt(e){let t=(0,Q.c)(2),n;t[0]===e?n=t[1]:(n=Zt(v(e)),t[0]=e,t[1]=n),D(n)}var $t=1500,en=.001;function tn(e){let t=(0,Q.c)(11),{zoomFactor:n}=e,[r,i]=(0,Z.useState)(!1),a=(0,Z.useRef)(n),o=(0,Z.useRef)(null),s,c;t[0]===n?(s=t[1],c=t[2]):(s=()=>{if(!(Math.abs(a.current-n)<en))return a.current=n,i(!0),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i(!1),o.current=null},$t),()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Z.useEffect)(s,c);let l;t[3]===n?l=t[4]:(l=Math.round(n*100),t[3]=n,t[4]=l);let u=`${l}%`,d=!r,f=r?`opacity-100 translate-y-0`:`opacity-0 -translate-y-1`,p;t[5]===f?p=t[6]:(p=y(`pointer-events-none absolute top-3 right-3 z-20 select-none rounded-full border border-border/70 bg-popover/95 px-2.5 py-1 text-xs font-medium text-foreground shadow-md/10 backdrop-blur transition-all duration-200 ease-out`,f),t[5]=f,t[6]=p);let m;return t[7]!==u||t[8]!==d||t[9]!==p?(m=(0,$.jsx)(`div`,{"aria-hidden":d,className:p,children:u}),t[7]=u,t[8]=d,t[9]=p,t[10]=m):m=t[10],m}function nn(e,t){return e?1:t===`human`?.18:.35}var rn=700;function an(e){let t=(0,Q.c)(9),{tabId:n,zoomFactor:r,controller:i}=e,a;t[0]===n?a=t[1]:(a=e=>e.byTabId[n]??null,t[0]=n,t[1]=a);let o=Ce(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=fe(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(on,{event:o,content:c,zoomFactor:r,controller:i},o.sequence),t[4]=c,t[5]=i,t[6]=o,t[7]=r,t[8]=l):l=t[8],l}function on(e){let t=(0,Q.c)(15),{event:n,content:r,zoomFactor:i,controller:a}=e,[o,s]=(0,Z.useState)(!0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=window.setTimeout(()=>s(!1),rn);return()=>window.clearTimeout(e)},l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,Z.useEffect)(c,l);let u;t[2]!==o||t[3]!==a?(u=nn(o,a),t[2]=o,t[3]=a,t[4]=u):u=t[4];let d=`translate3d(${n.x*i*(r?.scale??1)+(r?.x??0)-(r?.scrollLeft??0)}px, ${n.y*i*(r?.scale??1)+(r?.y??0)-(r?.scrollTop??0)}px, 0)`,f;t[5]!==u||t[6]!==d?(f={opacity:u,transform:d},t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;t[8]!==n.phase||t[9]!==n.sequence?(p=n.phase===`click`?(0,$.jsx)(`span`,{className:`absolute left-0.5 top-0.5 size-4 animate-status-ping rounded-full bg-primary/25 motion-reduce:animate-none`},n.sequence):null,t[8]=n.phase,t[9]=n.sequence,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(je,{className:`relative size-5 -translate-x-0.5 -translate-y-0.5 text-primary drop-shadow-sm`,weight:`fill`}),t[11]=m):m=t[11];let h;return t[12]!==f||t[13]!==p?(h=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute left-0 top-0 z-40 transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none`,style:f,"aria-hidden":`true`,"data-agent-browser-cursor":!0,children:[p,m]}),t[12]=f,t[13]=p,t[14]=h):h=t[14],h}var sn=typeof window>`u`?null:re();function cn({threadRef:e,tabId:t,configuredUrls:n,visible:r,onSendAnnotation:a}){let[o,s]=(0,Z.useState)(void 0),[c,l]=(0,Z.useState)(!1),u=be(),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(!0),m=(0,Z.useRef)(e);m.current=e;let h=Fe(e),g=Ke(e,50),_=q(t=>W(t.byThreadKey,e)),y=d(e=>e.addPreviewAnnotation),b=d(e=>e.addImage),x=ee(e.environmentId),S=x?new URL(x).hostname:null,C=P(Ye.open),w=P(Ye.resize,`preview viewport resize`);Qt(e),(0,Z.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let T=t??h.activeTabId,D=T?he(e,h.serverEpoch,T):null,O=T&&D?u.has(D)?D:we(e,T):null,k=T?h.sessions[T]??null:null,A=T?h.desktopByTabId[T]??null:null,M=k?.navStatus??{_tag:`Idle`},N=M._tag===`Idle`?``:M.url,te=A?.loading??M._tag===`Loading`,I=A?.canGoBack??k?.canGoBack??!1,ne=A?.canGoForward??k?.canGoForward??!1,re=M._tag===`Idle`,L=M._tag===`LoadFailed`,R=xe(k),ie=A?.controller??`none`,z=k?.viewport??i,B=_e(),ae=fe(e=>D?e.byTabId[D]?.rect??null:null),V=M._tag===`Success`?M.url:null,H=M._tag===`Success`?M.title:null,oe=g[0]?.url;(0,Z.useEffect)(()=>{!V||!H||!oe||Ue(m.current,V,H,S)},[S,oe,H,V,v(e)]);let G=(0,Z.useCallback)(async t=>D&&J?(await J.navigate(D,t),Ne(e,t),!0):(await se({openPreview:C,threadRef:e,url:t}))._tag===`Success`,[C,D,e]),K=(0,Z.useCallback)(async t=>{try{let n=We(t);await G(n)&&Ge(e,n)}catch{}},[G,e]),le=(0,Z.useCallback)(async t=>{try{let n=Be(e.environmentId,t);await G(n)&&Ge(e,t)}catch{}},[G,e]),Y=(0,Z.useCallback)(()=>{J&&D&&J.refresh(D)},[D]),ue=(0,Z.useCallback)(()=>{J&&D&&J.zoomIn(D)},[D]),pe=(0,Z.useCallback)(()=>{J&&D&&J.zoomOut(D)},[D]),Se=(0,Z.useCallback)(()=>{J&&D&&J.resetZoom(D)},[D]),Ce=(0,Z.useCallback)(async t=>{if(!T)return;let n=await w({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:T,viewport:t}});if(n._tag===`Failure`){let e=E(n);throw F.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}Me(e,n.value)},[w,T,e]),Ee=()=>{if(D){if(z._tag!==`fill`){me(D,i).catch(()=>void 0);return}me(D,ve({defaults:B,panelRect:ae,zoomFactor:A?.zoomFactor})).catch(()=>void 0)}};(0,Z.useEffect)(()=>{if(D)return Te(D,Ce)},[Ce,D]);let De=(0,Z.useCallback)(()=>{J&&D&&J.goBack(D)},[D]),Oe=(0,Z.useCallback)(()=>{J&&D&&J.goForward(D)},[D]),ke=(0,Z.useCallback)(()=>{!sn||!N||sn.shell.openExternal(N).catch(()=>void 0)},[N]),Ae=(0,Z.useCallback)(()=>{if(T){if(_?.tabId===T){q.getState().close(e);return}q.getState().open(e,T),Ze.getState().close(e)}},[_?.tabId,T,e]),je=(0,Z.useCallback)(()=>{!J||!D||(A?.pictureInPicture?J.pictureInPicture.close:J.pictureInPicture.open)(D).catch(e=>{F.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[A?.pictureInPicture,D]),Pe=(0,Z.useCallback)(t=>{if(!J||!D||!T)return;let n=J;if(O){de(O).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){F.update(r,j({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{t=!0,o(),window.setTimeout(()=>{t=!1,o()},2e3)},e=>{F.update(r,j({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:He(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{F.update(r,j({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=F.add(j({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{F.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(t){ge(D,e,T).catch(e=>{let t=e instanceof Error?e.message:`An error occurred.`;ye(e)||F.add({type:`error`,title:`Unable to start recording`,description:t})});return}n.captureScreenshot(D).then(e=>{let t={children:He(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{F.update(a,j({type:e,title:n,description:o,actionProps:{children:i?`Copied!`:`Copy image`,disabled:i,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:r?`Copied!`:`Copy path`,disabled:r,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},s=()=>{if(!navigator.clipboard?.writeText){o(`error`,`Unable to copy screenshot path`,`Clipboard API unavailable.`);return}navigator.clipboard.writeText(e.path).then(()=>{r=!0,o(),window.setTimeout(()=>{r=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot path`,e instanceof Error?e.message:`An error occurred.`)})},c=()=>{n.copyArtifactToClipboard(e.path).then(()=>{i=!0,o(),window.setTimeout(()=>{i=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot`,e instanceof Error?e.message:`An error occurred.`)})};a=F.add(j({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},e=>{F.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[O,D,T,e]),Ie=(0,Z.useCallback)(()=>{if(!J||!D)return;if(f.current){J.cancelPickElement(D).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;f.current=!0,l(!0),(async()=>{try{let t=await J.pickElement(D);if(!t)return;let{annotation:n,submission:r}=t;y(e,n);let i=null;try{i=await ce(n)}catch{}let o=i&&n.screenshot?{type:`image`,id:n.id,name:i.name,mimeType:i.type,sizeBytes:i.size,previewUrl:n.screenshot.dataUrl,file:i}:null;o&&b(e,o),r===`send`&&a?.(n,o)}catch{}finally{if(f.current=!1,p.current&&l(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[b,y,a,D,e]);return(0,Z.useEffect)(()=>()=>{f.current&&(f.current=!1,J&&D&&J.cancelPickElement(D).catch(()=>void 0),p.current&&l(!1))},[D]),(0,Z.useEffect)(()=>{if(r)return U(e=>{switch(e){case`refresh`:Y();return;case`focus-url`:s(e=>(e??0)+1);return;case`zoom-in`:ue();return;case`zoom-out`:pe();return;case`reset-zoom`:Se();return;case`toggle-panel`:return}})},[Y,Se,ue,pe,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":v(e),children:[(0,$.jsx)(St,{url:N,loading:te,canGoBack:I,canGoForward:ne,refreshDisabled:re,focusUrlNonce:o,onBack:De,onForward:Oe,onRefresh:Y,onSubmit:e=>void K(e),onOpenInBrowser:T?ke:void 0,onCapture:J&&T?Pe:void 0,captureDisabled:!A||L,recording:O!==null,onPictureInPicture:J&&T?Ae:void 0,pictureInPicture:_?.tabId===T,pictureInPictureDisabled:!A?.hasWebContents||L,onPickElement:J&&T?Ie:void 0,pickActive:c,pickDisabled:!T||L,pickDisabledReason:L?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:J?(0,$.jsx)(It,{tabId:D,hasWebContents:A?.hasWebContents??!1,zoomFactor:A?.zoomFactor??1,colorScheme:A?.colorScheme??`system`,deviceToolbarVisible:z._tag!==`fill`,onToggleDeviceToolbar:Ee,nativePictureInPicture:A?.pictureInPicture??!1,onNativePictureInPicture:je}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[D&&k&&!R?(0,$.jsx)(X,{tabId:D,visible:r&&!L,className:`absolute inset-0 h-full w-full`},D):null,R?(0,$.jsx)(Nt,{threadRef:e,environmentId:e.environmentId,configuredUrls:n,recentEntries:g,onRemoveRecent:t=>qe(e,t),onOpenUrl:e=>void le(e)}):null,k&&A?(0,$.jsx)(tn,{zoomFactor:A.zoomFactor}):null,D&&A&&!R&&!L?(0,$.jsx)(an,{tabId:D,zoomFactor:A.zoomFactor,controller:ie}):null,ie===`none`?null:(0,$.jsx)(`div`,{className:`surface-glass pointer-events-none absolute left-3 top-3 z-40 rounded-full px-2.5 py-1 text-[11px] font-medium shadow-glass`,children:ie===`agent`?`Agent controlling browser`:`Human control`}),M._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Kt,{url:M.url,code:M.code,description:M.description,onReload:Y})}):null]})]})}function ln(e){let t=(0,Q.c)(16),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o,onSendAnnotation:s}=e;if(!Xe()){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:(0,$.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:`Preview is only available in the Borg desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(Se,{mode:n,children:e}),t[1]=n,t[2]=r),r}let c;t[3]===i?c=t[4]:(c=i===void 0?{}:{tabId:i},t[3]=i,t[4]=c);let l;t[5]===s?l=t[6]:(l=s?{onSendAnnotation:s}:{},t[5]=s,t[6]=l);let u;t[7]!==a||t[8]!==c||t[9]!==l||t[10]!==r||t[11]!==o?(u=(0,$.jsx)(cn,{threadRef:r,...c,configuredUrls:a,visible:o,...l}),t[7]=a,t[8]=c,t[9]=l,t[10]=r,t[11]=o,t[12]=u):u=t[12];let d;return t[13]!==n||t[14]!==u?(d=(0,$.jsx)(Se,{mode:n,children:u}),t[13]=n,t[14]=u,t[15]=d):d=t[15],d}export{ln as PreviewPanel};
2
- //# sourceMappingURL=PreviewPanel-BVJp3UI5.js.map
@@ -1,6 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{a as t}from"./useLocalStorage-2W_I13tQ.js";import{Bo as n,Co as r,Mn as i,Nn as a,On as o,R as s,So as c,Vn as l,W as u,pt as d,t as ee,un as f,wo as te,xo as ne}from"./utils-D0kLIGeh.js";import{cn as p}from"./session-DIGL5_Nm.js";import{Ln as re,f as m,fr as ie,gr as h,hr as g,l as _,nr as v,o as y,t as b,u as x,ur as S,x as C,xt as w}from"./textarea-DdNchuIO.js";import{$t as T,Bn as E,Jt as D,Ln as O,Qt as ae,Rn as oe,Yt as se,en as k,tn as ce,zn as le}from"./scroll-area-D8MfzXjN.js";import{_ as ue,ut as de,v as fe,y as pe}from"./ChatMarkdown-Cl8M9HCx.js";import{$ as me,C as A,Mt as he,Ot as j,Pt as ge,c as _e,ht as ve,l as ye,n as be,o as xe,r as Se,st as Ce,t as we,xt as Te}from"./PullRequestReactions-BWjOU4KY.js";import{i as Ee,n as De,o as Oe,r as ke,s as Ae}from"./diffFileContents-Bj3q_jc2.js";import{s as je}from"./env-DgM3kOA4.js";import{l as Me,t as Ne}from"./DiffWorkerPoolProvider-_R9JGgmp.js";import{a as Pe,i as Fe}from"./VirtualizedFile-CyAKSbzc.js";import{n as Ie,t as Le}from"./toggle-group-iEMUfMdW.js";var M=e(t(),1),N=new Map([[`bold`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M56.88,31.93a12,12,0,0,0-20.29,4.38A20,20,0,0,0,20,56V184a20,20,0,0,0,20,20H98.11l12.52,21.92a20,20,0,0,0,34.73,0L157.89,204h23l18.25,20.07a12,12,0,0,0,17.76-16.14ZM150.93,180a12,12,0,0,0-10.42,6.05L128,207.94l-12.51-21.89A12,12,0,0,0,105.07,180H44V60h6l109.1,120ZM236,56V174.14a12,12,0,0,1-24,0V60H109.33a12,12,0,1,1,0-24H216A20,20,0,0,1,236,56Z`}))],[`duotone`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M224,56V184a8,8,0,0,1-8,8H150.93l-16,28a8,8,0,0,1-13.9,0l-16-28H40a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z`,opacity:`0.2`}),M.createElement(`path`,{d:`M53.92,34.62A8,8,0,0,0,40,40h0A16,16,0,0,0,24,56V184a16,16,0,0,0,16,16h60.43l13.68,23.94a16,16,0,0,0,27.78,0L155.57,200h27.07l19.44,21.38a8,8,0,1,0,11.84-10.76Zm97,149.38a8,8,0,0,0-7,4l-16,28-16-28a8,8,0,0,0-7-4H40V56H51.73L168.1,184ZM232,56V186a8,8,0,0,1-16,0V56H98.52a8,8,0,1,1,0-16H216A16,16,0,0,1,232,56Z`}))],[`fill`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M232,56V184a15.93,15.93,0,0,1-4.82,11.42,4,4,0,0,1-5.68-.25L86.52,46.69a4,4,0,0,1,3-6.69H216A16,16,0,0,1,232,56ZM53.92,34.62A8,8,0,0,0,40,40h0A16,16,0,0,0,24,56V184a16,16,0,0,0,16,16h60.43l13.68,23.94a16,16,0,0,0,27.78,0L155.57,200h27.07l19.44,21.38a8,8,0,1,0,11.84-10.76Z`}))],[`light`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M52.44,36a6,6,0,0,0-10.1,6H40A14,14,0,0,0,26,56V184a14,14,0,0,0,14,14h61.59L115.84,223a14,14,0,0,0,24.32,0L154.41,198h29.12l20,22a6,6,0,0,0,8.88-8.08Zm98.49,150a6,6,0,0,0-5.21,3l-16,28a2,2,0,0,1-3.48,0l-16-28a6,6,0,0,0-5.21-3H40a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H52.62l120,132ZM230,56V186a6,6,0,0,1-12,0V56a2,2,0,0,0-2-2H98.52a6,6,0,1,1,0-12H216A14,14,0,0,1,230,56Z`}))],[`regular`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M53.92,34.62A8,8,0,0,0,40,40h0A16,16,0,0,0,24,56V184a16,16,0,0,0,16,16h60.43l13.68,23.94a16,16,0,0,0,27.78,0L155.57,200h27.07l19.44,21.38a8,8,0,1,0,11.84-10.76Zm97,149.38a8,8,0,0,0-7,4l-16,28-16-28a8,8,0,0,0-7-4H40V56H51.73L168.1,184ZM232,56V186a8,8,0,0,1-16,0V56H98.52a8,8,0,1,1,0-16H216A16,16,0,0,1,232,56Z`}))],[`thin`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M51,37.31A4,4,0,0,0,45,42.69L46.23,44H40A12,12,0,0,0,28,56V184a12,12,0,0,0,12,12h62.75L117.58,222a12,12,0,0,0,20.84,0L153.25,196h31.16L205,218.69a4,4,0,1,0,5.92-5.38ZM150.93,188a4,4,0,0,0-3.47,2l-16,28a4,4,0,0,1-6.94,0l-16-28a4,4,0,0,0-3.47-2H40a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H53.5L177.14,188ZM228,56V186a4,4,0,0,1-8,0V56a4,4,0,0,0-4-4H98.52a4,4,0,1,1,0-8H216A12,12,0,0,1,228,56Z`}))]]),Re=new Map([[`bold`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Z`}))],[`duotone`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),M.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z`}))],[`fill`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M232,128A104,104,0,1,1,128,24,104.13,104.13,0,0,1,232,128Z`}))],[`light`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Z`}))],[`regular`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z`}))],[`thin`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Z`}))]]),ze=Object.defineProperty,P=Object.defineProperties,F=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,L=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable,Ve=(e,t,n)=>t in e?ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,He=(e,t)=>{for(var n in t||={})L.call(t,n)&&Ve(e,n,t[n]);if(I)for(var n of I(t))Be.call(t,n)&&Ve(e,n,t[n]);return e},Ue=(e,t)=>P(e,F(t)),We=(0,M.forwardRef)((e,t)=>M.createElement(r,Ue(He({ref:t},e),{weights:N})));We.displayName=`ChatCenteredSlash`;var Ge=Object.defineProperty,R=Object.defineProperties,z=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable,U=(e,t,n)=>t in e?Ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W=(e,t)=>{for(var n in t||={})V.call(t,n)&&U(e,n,t[n]);if(B)for(var n of B(t))H.call(t,n)&&U(e,n,t[n]);return e},G=(e,t)=>R(e,z(t)),K=(0,M.forwardRef)((e,t)=>M.createElement(r,G(W({ref:t},e),{weights:Re})));K.displayName=`Circle`;var Ke=new Set([`pnpm-lock.yaml`,`yarn.lock`,`package-lock.json`,`bun.lockb`,`Cargo.lock`,`go.sum`,`composer.lock`,`Gemfile.lock`]),qe=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),Je=new Set([`__tests__`,`tests`,`test`]),Ye=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function Xe(e){let t=e.split(`/`),n=t.at(-1)??``;return Ke.has(n)||n.endsWith(`.snap`)||n.endsWith(`.min.js`)||n.endsWith(`.min.css`)||/\.generated\./.test(n)||t.slice(0,-1).some(e=>qe.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>Je.has(e))?`test`:`source`}function Ze(e){let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(0,t):e}function Qe(e){return Ze(e.split(`/`).at(-1)??``)}function $e(e,t){let n=e.split(`/`).slice(0,-1);for(let e of t.split(`/`))e===`.`||e===``||(e===`..`?n.pop():n.push(e));return n.join(`/`)}var et=/(?:\bfrom|\bimport|\brequire\s*\()\s*\(?\s*["']([^"']+)["']/g;function tt(e,t,n,r){let i=new Set;for(let a of t){et.lastIndex=0;let t=et.exec(a);for(;t!==null;){let o=t[1]??``,s=o.startsWith(`.`)?$e(e,o):o,c=Ye.find(e=>s.endsWith(e)),l=c===void 0?s:s.slice(0,-c.length),u=n.get(l)??n.get(`${l}/index`)??r.get(Qe(l));u!==void 0&&u!==e&&i.add(u),t=et.exec(a)}}return i}function nt(e,t){let n=new Set(e),r=[],i=[...e].sort((e,t)=>e.localeCompare(t));for(;n.size>0;){let e=i.filter(e=>n.has(e)),a=e.find(e=>[...t.get(e)??[]].every(e=>!n.has(e)))??e[0];n.delete(a),r.push(a)}return r}function rt(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function it(e){let t=new Map;for(let n of e)t.set(k(n),n);let n=new Map;for(let e of t.keys())n.set(e,Xe(e));let r=[...t.keys()].filter(e=>n.get(e)===`source`),i=new Map,a=new Set,o=new Map;for(let e of r){i.set(Ze(e),e);let t=Qe(e);o.has(t)&&a.add(t),o.set(t,e)}for(let e of a)o.delete(e);let s=new Map;for(let e of r){let n=t.get(e);s.set(e,tt(e,[...n.additionLines,...n.deletionLines],i,o))}let c=nt(r,s),l=new Map;c.forEach((e,t)=>{let n=Qe(e);l.has(n)||l.set(n,t)});let u=[...t.keys()].filter(e=>n.get(e)===`test`).sort((e,t)=>(l.get(rt(e))??2**53-1)-(l.get(rt(t))??2**53-1)||e.localeCompare(t)),d=[...t.keys()].filter(e=>n.get(e)===`generated`).sort((e,t)=>e.localeCompare(t));return[...c,...u,...d].map(e=>t.get(e))}var q=te(),J=n(),Y=`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 text-sm shadow-sm`;function at(e){return t=>{t.key===`Escape`&&e.onCancel&&(t.preventDefault(),e.onCancel()),Pe(t,e.value,e.pending)&&(t.preventDefault(),e.onSubmit())}}function ot(e){let t=(0,q.c)(11),{comment:n,onRemove:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=ee(Y,`border-dashed`),t[0]=i):i=t[0];let a,o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,J.jsx)(de,{className:`size-3.5`}),o=(0,J.jsx)(`span`,{children:`Pending — sent when you submit the review`}),t[1]=a,t[2]=o):(a=t[1],o=t[2]);let s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,J.jsx)(O,{className:`size-3.5`}),t[3]=s):s=t[3];let c;t[4]===r?c=t[5]:(c=(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[a,o,(0,J.jsx)(f,{size:`icon-xs`,variant:`ghost`,className:`ml-auto`,"aria-label":`Discard this comment`,onClick:r,children:s})]}),t[4]=r,t[5]=c);let l;t[6]===n.body?l=t[7]:(l=(0,J.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap leading-relaxed`,children:n.body}),t[6]=n.body,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,J.jsxs)(`div`,{className:i,contentEditable:!1,onPointerDown:X,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u}function X(e){return e.stopPropagation()}function st({thread:e,workspaceRoot:t,canReply:n,canResolve:r,canReact:i,environmentId:a,reference:o,pending:s,fixPending:c,fixLabel:l=`Fix in a thread`,onFix:u,onReply:d,onLoadMore:ee,canEditComment:te,onEditComment:ne,onToggleResolved:p,onReacted:re}){let[m,ie]=(0,M.useState)(!e.isResolved),[h,_]=(0,M.useState)(!1),[v,y]=(0,M.useState)(``),[x,S]=(0,M.useState)(null),[C,w]=(0,M.useState)(!1),T=(0,M.useRef)(!1),[E,D]=(0,M.useState)(null),[O,ae]=(0,M.useState)(!1),oe=E?.threadId===e.id?E:null,se=ve(e.comments,oe?.comments??[]),k=oe===null?e.nextCommentsCursor??null:oe.nextCursor,ce=e.commentCount??se.length,le=async(t,n)=>{if(C)return;w(!0);let r=await ne(t,n);w(!1),r&&(D(r=>r?.threadId===e.id?{...r,comments:Ce(r.comments,t,n)}:r),S(null))},ue=async()=>{let t=v.trim();if(!(t.length===0||s||T.current)){T.current=!0;try{await d(t)&&(D(t=>t?.threadId===e.id?{...t,nextCursor:t.nextCursor??e.nextCommentsCursor??null}:t),y(``),_(!1))}finally{T.current=!1}}},de=async()=>{if(!(k===null||O)){ae(!0);try{let t=await ee(k);if(t===null)return;D(n=>({threadId:e.id,comments:ve(n?.threadId===e.id?n.comments:[],t.comments),nextCursor:t.nextCursor}))}finally{ae(!1)}}};return(0,J.jsxs)(`div`,{className:Y,contentEditable:!1,onPointerDown:e=>e.stopPropagation(),children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.isResolved?(0,J.jsx)(g,{className:`size-3.5 text-emerald-600 dark:text-emerald-500`}):(0,J.jsx)(K,{className:`size-3.5`}),(0,J.jsxs)(`button`,{type:`button`,className:`hover:text-foreground`,"aria-expanded":m,onClick:()=>ie(e=>!e),children:[e.isResolved?`Resolved`:`Open`,` · `,ce,` `,ce===1?`comment`:`comments`]}),e.isOutdated?(0,J.jsx)(`span`,{children:`outdated`}):null,u?(0,J.jsxs)(f,{size:`xs`,variant:`ghost`,className:`ml-auto`,disabled:s||c,onClick:u,children:[(0,J.jsx)(ge,{className:`size-3`}),c?`Preparing...`:l]}):null,r?(0,J.jsx)(f,{size:`xs`,variant:`ghost`,className:u?void 0:`ml-auto`,disabled:s,onClick:p,children:e.isResolved?`Unresolve`:`Resolve`}):null]}),m?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`mt-2 space-y-3`,children:se.map(e=>(0,J.jsxs)(`article`,{className:`group min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(xe,{actor:e.author,className:`text-foreground`}),(0,J.jsx)(`span`,{children:je(e.createdAt)})]}),x===e.id?(0,J.jsx)(be,{className:`mt-1`,value:e.body,cwd:t,environmentId:a,label:`Edit comment`,saving:C,onSave:t=>void le(e.id,t),onCancel:()=>S(null)}):(0,J.jsxs)(`div`,{className:`mt-1 flex items-start gap-1`,children:[(0,J.jsx)(Se,{className:`min-w-0 flex-1 text-sm`,text:e.body,cwd:t,environmentId:a}),te(e)?(0,J.jsx)(f,{size:`icon-xs`,variant:`ghost`,className:`shrink-0 text-muted-foreground opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:opacity-100`,"aria-label":`Edit comment`,onClick:()=>S(e.id),children:(0,J.jsx)(he,{className:`size-3`})}):null]}),(0,J.jsx)(we,{className:`mt-1.5`,reactions:e.reactions??[],canReact:i,subjectId:e.id,environmentId:a,reference:o,onRefresh:re})]},e.id))}),k===null?null:(0,J.jsx)(`div`,{className:`mt-2`,children:(0,J.jsx)(f,{size:`xs`,variant:`ghost`,className:`px-1`,disabled:O,onClick:()=>void de(),children:O?`Loading...`:`Load more comments`})}),n?h?(0,J.jsxs)(`div`,{className:`mt-2`,children:[(0,J.jsx)(b,{autoFocus:!0,size:`sm`,value:v,placeholder:`Reply`,"aria-label":`Reply to this conversation`,onChange:e=>y(e.target.value),onKeyDown:at({value:v,pending:s,onSubmit:()=>void ue(),onCancel:()=>_(!1)})}),(0,J.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,J.jsx)(f,{size:`xs`,variant:`ghost`,onClick:()=>_(!1),children:`Cancel`}),(0,J.jsx)(f,{size:`xs`,disabled:s||v.trim().length===0,onClick:()=>void ue(),children:`Reply`})]})]}):(0,J.jsx)(f,{size:`xs`,variant:`ghost`,className:`mt-2 px-1`,onClick:()=>_(!0),children:`Reply`}):null]}):null]})}var Z=0;function ct(){return Z+=1,`pending-review-comment-${Z}`}function lt(e){return`${e.projectId}/${e.repository}#${e.number}`}var ut=[],Q=d()(e=>({drafts:{},summaries:{},addComment:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:[...e.drafts[t]??ut,n]}})),removeComment:(t,n)=>e(e=>{let r=(e.drafts[t]??ut).filter(e=>e.id!==n);if(r.length>0)return{drafts:{...e.drafts,[t]:r}};let{[t]:i,...a}=e.drafts;return{drafts:a}}),removeComments:(t,n)=>e(e=>{let r=new Set(n),i=(e.drafts[t]??ut).filter(e=>!r.has(e.id));if(i.length>0)return{drafts:{...e.drafts,[t]:i}};let{[t]:a,...o}=e.drafts;return{drafts:o}}),clear:t=>e(e=>{let{[t]:n,...r}=e.drafts;return{drafts:r}}),setSummary:(t,n)=>e(e=>({summaries:{...e.summaries,[t]:n}})),clearSummary:(t,n)=>e(e=>{if(e.summaries[t]!==n)return e;let{[t]:r,...i}=e.summaries;return{summaries:i}})}));function dt(e){let t=(0,q.c)(2),n;return t[0]===e?n=t[1]:(n=t=>t.drafts[lt(e)]??ut,t[0]=e,t[1]=n),Q(n)}var ft=[{value:`comment`,label:`Comment`,sent:`Review submitted`,icon:(0,J.jsx)(de,{className:`size-3`})},{value:`approve`,label:`Approve`,sent:`Pull request approved`,icon:(0,J.jsx)(h,{className:`size-3`})},{value:`request-changes`,label:`Request changes`,sent:`Changes requested`,icon:(0,J.jsx)(j,{className:`size-3`})}];function pt(e){let t=(0,q.c)(13),{environmentId:n,reference:r,verdicts:i,onSubmitted:a}=e,[o,s]=(0,M.useState)(!1),c=dt(r),l=lt(r),u=Q(e=>e.summaries[l]??``),d=Q(_t),ee=Q(gt),te=Q(ht),ne=Q(mt),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p={reportFailure:!1},t[0]=p):p=t[0];let re=v(A.submitReview,p),m;t[1]===i?m=t[2]:(m=e=>i.includes(e.value),t[1]=i,t[2]=m);let ie=ft.filter(m);if(ie.length===0)return null;let h=async e=>{if(o)return;let t=u,i=c;s(!0);let d=await re({environmentId:n,input:{...r,verdict:e.value,body:t,comments:i}});if(s(!1),d._tag===`Failure`){y.add({type:`error`,title:`The review could not be submitted`});return}ee(l,i.map($)),ne(l,t),y.add({type:`success`,title:e.sent}),a()},g;t[3]!==u||t[4]!==c.length?(g=e=>e===`approve`||u.trim().length>0||c.length>0,t[3]=u,t[4]=c.length,t[5]=g):g=t[5];let _=g,x=c.length===0?`No line comments yet`:`${c.length} ${c.length===1?`comment`:`comments`} pending`,S;t[6]===x?S=t[7]:(S=(0,J.jsx)(`span`,{children:x}),t[6]=x,t[7]=S);let C=c.length>0?(0,J.jsx)(f,{size:`xs`,variant:`ghost`,disabled:o,onClick:()=>d(l),children:`Discard`}):null,w;t[8]!==S||t[9]!==C?(w=(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[S,C]}),t[8]=S,t[9]=C,t[10]=w):w=t[10];let T=ie.map(e=>(0,J.jsx)(f,{size:`xs`,variant:e.value===`comment`?`outline`:`default`,disabled:o||!_(e.value),onClick:()=>void h(e),children:(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.icon,e.label]})},e.value)),E;return t[11]===T?E=t[12]:(E=(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:T}),t[11]=T,t[12]=E),(0,J.jsxs)(`div`,{className:`px-4 py-3`,children:[w,(0,J.jsx)(b,{size:`sm`,className:`mt-2`,value:u,placeholder:`Summarize your review (optional)`,"aria-label":`Review summary`,onChange:e=>te(l,e.target.value)}),E]})}function $(e){return e.id}function mt(e){return e.clearSummary}function ht(e){return e.setSummary}function gt(e){return e.removeComments}function _t(e){return e.clear}function vt(e,t,n){return e.hunks.some(e=>t===`left`?n>=e.deletionStart&&n<e.deletionStart+e.deletionCount:n>=e.additionStart&&n<e.additionStart+e.additionCount)}function yt(e,t,n){let r=t===`folded`;return n.has(e)?!r:r}var bt=10,xt=`
2
- [data-diffs-header] [data-additions-count],
3
- [data-diffs-header] [data-deletions-count] {
4
- display: none !important;
5
- }`,St=[];function Ct(e){return e===`left`?`deletions`:`additions`}function wt(e){switch(e.kind){case`added`:return{line:e.newLine,side:`right`};case`deleted`:return{line:e.oldLine,side:`left`};case`context`:return{line:e.side===`left`?e.oldLine:e.newLine,side:e.side}}}function Tt({environmentId:e,reference:t,detail:n,selectedCommitOid:r,onSelectedCommitChange:d,pendingFinding:te,fixFindingLabel:h=`Fix in a thread`,onFixFinding:g,onAddToAgentSelection:b,onRefresh:O,refreshToken:he=0}){let{resolvedTheme:j}=w(),ge=C(),[ve,be]=(0,M.useState)(()=>new Set),[xe,Se]=(0,M.useState)(bt),[Ce,we]=(0,M.useState)(null),[je,Pe]=(0,M.useState)(`stacked`),[N,Re]=(0,M.useState)(ge.wordWrap),[ze,P]=(0,M.useState)(null),[F,I]=(0,M.useState)(null),[L,Be]=(0,M.useState)(!1),[Ve,He]=(0,M.useState)(!1),[Ue,Ge]=(0,M.useState)(!1),[R,z]=(0,M.useState)({key:``,cursor:null,slices:St}),B=(0,M.useRef)(new Map),V=lt(t),H=r,U=H===null?V:`${V}@${H}`;(0,M.useEffect)(()=>{I(null),P(null),be(new Set),we(null),Se(bt),He(!1),z({key:U,cursor:null,slices:St}),B.current.clear()},[U]);let W=R.key===U?R.slices:St,G=R.key===U?R.cursor:null,K=re(A.diff({environmentId:e,input:{...t,...G===null?{}:{cursor:G},...H===null?{}:{commit:H}}}));(0,M.useEffect)(()=>{let e=K.data;e!==null&&z(t=>{let n=t.key===U?t.slices:St,r={cursor:G,patch:e.patch,truncated:e.truncated,nextCursor:e.nextCursor,omittedFileStats:e.omittedFileStats??[]},i=n.findIndex(e=>e.cursor===G);if(i===-1)return{key:U,cursor:G,slices:[...n,r]};let a=n[i];return a!==void 0&&a.patch===r.patch&&a.truncated===r.truncated&&a.nextCursor===r.nextCursor&&a.omittedFileStats.length===r.omittedFileStats.length&&a.omittedFileStats.every((e,t)=>{let n=r.omittedFileStats[t];return n!==void 0&&n.path===e.path&&n.additions===e.additions&&n.deletions===e.deletions})?t:{key:U,cursor:G,slices:[...n.slice(0,i),r]}})},[G,K.data,U]);let Ke=p(A.diff({environmentId:e,input:{...t,...H===null?{}:{commit:H}}})),qe=(0,M.useRef)(he);(0,M.useEffect)(()=>{qe.current!==he&&(qe.current=he,z({key:U,cursor:null,slices:St}),Ke())},[he,U,Ke]);let Je=V,Ye=dt(t),Xe=Q(e=>e.addComment),Ze=Q(e=>e.removeComment),Qe=v(A.replyToThread,{reportFailure:!1}),$e=v(A.setThreadResolution,{reportFailure:!1}),et=v(A.updateComment,{reportFailure:!1}),tt=v(A.threadComments,{reportFailure:!1}),nt=v(A.diffFileContents),rt=(0,M.useMemo)(()=>De(nt,{environmentId:e,reference:t,commit:H,cacheKey:`pull-request:${V}:${n.updatedAt}:${H??`all`}`}),[H,n.updatedAt,e,nt,t,V]),q=(0,M.useMemo)(()=>{let e=n.capabilities.review,t=n.viewerPermissions;return{inlineComment:e.inlineComment&&t.comment,reply:e.reply&&t.comment,resolve:e.resolve&&t.resolve,verdicts:e.verdicts.filter(e=>t.verdicts.includes(e))}},[n.capabilities.review,n.viewerPermissions]),Y=q.inlineComment&&H===null,at=(0,M.useMemo)(()=>W.map(e=>{let t=`pull-request:${U}:${j}:${e.cursor??`first`}:${se(e.patch)}`,n=B.current.get(t);if(n)return n;let r=ae(e.patch,t,{compactPartialHunkOffsets:!0});return r&&B.current.set(t,r),r}),[W,j,U]),X=(0,M.useMemo)(()=>at.flatMap(e=>e?.kind===`files`?it(e.files):[]),[at]),Z=W.at(-1)?.nextCursor??null,ut=W.some(e=>e.truncated)||at.some(e=>e?.kind===`raw`),ft=(0,M.useMemo)(()=>{let e=new Set;if(H!==null)return e;for(let t of X){let r=k(t);for(let i of n.reviewThreads)i.path===r&&i.line!==null&&vt(t,i.side,i.line)&&e.add(i.id)}return e},[H,n.reviewThreads,X]),$=(0,M.useMemo)(()=>X.map(e=>{let t=D(e),r=k(e),i=new Map,a=(e,t)=>{let n=`${e}:${t}`,r=i.get(n);if(r)return r;let a={side:e,line:t,threads:[],pending:[],draft:!1};return i.set(n,a),a};for(let e of n.reviewThreads)e.path!==r||e.line===null||ft.has(e.id)&&a(e.side,e.line).threads.push(e);if(H===null)for(let e of Ye){if(e.path!==r)continue;let t=wt(e.position);a(t.side,t.line).pending.push(e)}if(F?.fileKey===t){let e=wt(F.position);a(e.side,e.line).draft=!0}let o=yt(t,Ce,ve),s=[...i.values()].map(e=>({side:Ct(e.side),lineNumber:e.line,metadata:{threads:e.threads,pending:e.pending,draft:e.draft}}));return{id:t,type:`diff`,fileDiff:e,annotations:s,collapsed:o,version:se(`${o?`1`:`0`}:${s.map(({side:e,lineNumber:t,metadata:n})=>`${e}:${t}:${n.draft?`d`:``}:${n.pending.map(e=>`${e.id}:${e.body}`).join(`,`)}:${n.threads.map(e=>`${e.id}:${e.isResolved?`r`:``}:${e.isOutdated?`o`:``}:${e.comments.map(e=>`${e.id}:${e.author?.login??``}:${e.createdAt}:${e.body}:${(e.reactions??[]).map(e=>`${e.content}:${e.count}:${e.viewerHasReacted?`v`:``}`).join(`,`)}`).join(`;`)}`).join(`,`)}`).join(`|`)}`)}}),[H,n.reviewThreads,F,X,Ce,Ye,ft,ve]),mt=(0,M.useMemo)(()=>new Map(W.flatMap(e=>e.omittedFileStats.map(e=>[e.path,e]))),[W]),ht=(0,M.useMemo)(()=>$.map(e=>e.id),[$]),gt=(0,M.useMemo)(()=>new Set($.filter(e=>e.collapsed===!0).map(e=>e.id)),[$]),_t=Ee(ht,gt),[Tt,Et]=(0,M.useState)(null);(0,M.useEffect)(()=>{if(Tt===null||Z===null||Z===G||K.isPending||K.error!==null)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&z(e=>({...e,cursor:Z}))},{rootMargin:`240px`});return e.observe(Tt),()=>e.disconnect()},[G,K.error,K.isPending,Z,Tt]);let Dt=(0,M.useCallback)(e=>be(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),Ot=()=>{we(Ee(ht,gt)?`expanded`:`folded`),be(new Set)},kt=(0,M.useMemo)(()=>n.commits.toSorted((e,t)=>Date.parse(t.committedDate)-Date.parse(e.committedDate)),[n.commits]),At=(0,M.useCallback)((e,t)=>{if(!e||!Y)return;let n=t.item;if(n.type!==`diff`)return;let r=X.find(e=>D(e)===n.id);if(!r)return;let i=k(r),a=ce(r),o=u(r,e.end,e.endSide??e.side);o!==null&&I({fileKey:n.id,path:i,oldPath:a===i?null:a,position:o,range:e})},[Y,X]),jt=(0,M.useCallback)((e,t,r)=>{let i=X.find(t=>D(t)===e.fileKey),a=i===void 0?null:s({id:`pull-request-selection:${e.fileKey}:${e.range.start}:${e.range.end}`,sectionId:`pull-request:${n.number}`,sectionTitle:`PR #${n.number} review`,filePath:e.path,fileDiff:i,range:e.range,text:t});I(null),P(null),a!==null&&r(a)},[n.number,X]),Mt=(0,M.useCallback)(()=>Z===null?null:(0,J.jsx)(`div`,{ref:Et,className:`flex items-center justify-center gap-2 py-2 text-xs text-muted-foreground`,children:K.error===null?K.isPending?`Loading more files...`:null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`The rest of this diff could not be loaded.`}),(0,J.jsx)(f,{size:`xs`,variant:`outline`,onClick:()=>K.refresh(),children:`Retry`})]})}),[Z,K.error,K.isPending,K.refresh]),Nt=(0,M.useCallback)(e=>{let t=e.collapsed===!0;return(0,J.jsx)(f,{size:`icon-micro`,variant:`ghost-muted`,"aria-expanded":!t,"aria-label":t?`Expand diff`:`Collapse diff`,className:`mr-1 rounded hover:bg-transparent`,onClick:t=>{t.stopPropagation(),Dt(e.id)},children:t?(0,J.jsx)(ne,{className:`size-4`}):(0,J.jsx)(c,{className:`size-4`})})},[Dt]),Pt=(0,M.useCallback)(e=>{if(e.type!==`diff`)return null;let t=0,n=0;for(let r of e.fileDiff.hunks)t+=r.additionLines,n+=r.deletionLines;if(t===0&&n===0){let r=mt.get(k(e.fileDiff));r&&({additions:t,deletions:n}=r)}return(0,J.jsx)(_e,{additions:t,deletions:n,className:`font-mono text-[11px]`})},[mt]),Ft=(0,M.useMemo)(()=>({diffStyle:je===`split`?`split`:`unified`,lineDiffType:`none`,overflow:N?`wrap`:`scroll`,theme:T(j),themeType:j,stickyHeaders:!0,loadDiffFiles:rt,enableGutterUtility:Y&&F===null,enableLineSelection:Y&&F===null,onGutterUtilityClick:At,onLineSelectionEnd:At}),[je,N,j,rt,Y,F,At]),It=(0,M.useCallback)(async(e,t)=>{if(L)return!1;Be(!0);let n=await t();return Be(!1),n._tag===`Failure`?(y.add({type:`error`,title:e}),!1):(O(),!0)},[O,L]),Lt=(0,M.useCallback)(r=>(0,J.jsx)(st,{thread:r,workspaceRoot:n.workspaceRoot,canReply:q.reply,canResolve:q.resolve,canReact:n.capabilities.reactions===!0,environmentId:e,reference:t,pending:L,fixPending:te===Te({kind:`thread`,thread:r}),fixLabel:h,...g?{onFix:()=>g({kind:`thread`,thread:r})}:{},onLoadMore:async n=>{let i=await tt({environmentId:e,input:{...t,threadId:r.id,cursor:n}});return i._tag===`Failure`?(y.add({type:`error`,title:`More comments could not be loaded`}),null):i.value},onReply:n=>It(`Reply could not be posted`,()=>Qe({environmentId:e,input:{...t,threadId:r.id,body:n}})),canEditComment:e=>me(n,{author:e.author,kind:`review-comment`}),onEditComment:(n,r)=>It(`The comment could not be saved`,()=>et({environmentId:e,input:{...t,commentId:n,kind:`review-comment`,body:r}})),onToggleResolved:()=>void It(`The conversation could not be updated`,()=>$e({environmentId:e,input:{...t,threadId:r.id,resolved:!r.isResolved}})),onReacted:O},`${t.projectId}#${t.number}:${r.id}`),[n,e,h,tt,O,g,te,t,Qe,q.reply,q.resolve,It,$e,L,et]),Rt=(0,M.useCallback)(e=>(0,J.jsxs)(`div`,{className:`py-1 font-sans text-foreground`,children:[e.metadata.threads.map(Lt),e.metadata.pending.map(e=>(0,J.jsx)(ot,{comment:e,onRemove:()=>Ze(Je,e.id)},e.id)),e.metadata.draft&&F?(0,J.jsx)(Fe,{kind:`draft`,rangeLabel:`${F.path}:${wt(F.position).line}`,text:``,submitLabel:`Add to review`,...b?{secondaryAction:{label:`Add to agent`,onAction:e=>jt(F,e,t=>b({comment:t,request:e}))}}:{},onCancel:()=>{I(null),P(null)},onComment:e=>{Xe(Je,{id:ct(),path:F.path,...F.oldPath===null?{}:{oldPath:F.oldPath},position:F.position,body:e}),I(null),P(null)}}):null]}),[Xe,F,jt,b,Ze,Lt,Je]),zt=q.verdicts.length===0?null:(0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:Ue?(0,J.jsxs)(`div`,{className:`surface-glass pointer-events-auto absolute inset-x-3 bottom-3 rounded-xl border border-border/60 shadow-lg`,children:[(0,J.jsx)(f,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close review`,className:`absolute right-2 top-2`,onClick:()=>Ge(!1),children:(0,J.jsx)(S,{className:`size-3.5`})}),(0,J.jsx)(pt,{environmentId:e,reference:t,verdicts:q.verdicts,onSubmitted:()=>{O(),Ge(!1)}})]}):(0,J.jsxs)(f,{className:`pointer-events-auto absolute right-4 bottom-3 rounded-full shadow-lg`,onClick:()=>Ge(!0),size:`compact`,variant:`glass`,children:[(0,J.jsx)(de,{className:`size-3.5`}),`Review`,Ye.length>0?(0,J.jsx)(`span`,{className:`flex size-4 items-center justify-center rounded-full bg-accent text-[10px] tabular-nums text-accent-foreground`,children:Ye.length}):null]})}),Bt=kt.find(e=>e.oid===H);(0,M.useEffect)(()=>{H!==null&&Bt===void 0&&d(null)},[H,d,Bt]);let Vt=Bt?Bt.messageHeadline:`All commits`,Ht=(0,J.jsxs)(`div`,{className:`flex h-10 min-h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 bg-background px-4 text-xs text-muted-foreground`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[kt.length>0?(0,J.jsxs)(o,{children:[(0,J.jsxs)(l,{className:`inline-flex h-6 min-w-0 max-w-64 items-center gap-1 rounded-md bg-accent px-2 text-xs font-medium text-accent-foreground outline-none transition-colors hover:bg-accent/80 focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${Vt}`,children:[(0,J.jsx)(`span`,{className:`truncate`,children:Vt}),(0,J.jsx)(c,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,J.jsxs)(a,{align:`start`,className:`w-80`,children:[(0,J.jsx)(i,{className:H===null?`bg-foreground/[0.08]`:void 0,onClick:()=>d(null),children:(0,J.jsx)(`span`,{children:`All commits`})}),kt.slice(0,xe).map(e=>(0,J.jsxs)(i,{className:e.oid===H?`bg-foreground/[0.08]`:void 0,onClick:()=>d(e.oid),children:[(0,J.jsxs)(_,{children:[(0,J.jsx)(m,{render:(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.messageHeadline})}),(0,J.jsx)(x,{side:`top`,children:e.messageHeadline})]}),(0,J.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-xs text-muted-foreground`,children:e.oid.slice(0,7)})]},e.oid)),kt.length>xe?(0,J.jsx)(i,{closeOnClick:!1,onClick:()=>Se(e=>e+bt),children:(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Show more (`,kt.length-xe,` left)`]})}):null]})]}):null,(0,J.jsxs)(ye,{className:`shrink-0`,children:[(0,J.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[X.length,` `,X.length===1?`file`:`files`,Z===null?``:`+`]}),ut?(0,J.jsxs)(_,{children:[(0,J.jsx)(m,{render:(0,J.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,J.jsx)(ie,{"aria-label":`Some of this diff was not shown`,className:`size-3.5 text-amber-600 dark:text-amber-500`})}),(0,J.jsx)(x,{side:`bottom`,children:`The host withheld part of this diff — a binary file, or a change too large to inline.`})]}):null,H!==null&&q.inlineComment?(0,J.jsxs)(_,{children:[(0,J.jsx)(m,{render:(0,J.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,J.jsx)(We,{"aria-label":`Line comments are written from the whole change`,className:`size-3.5`})}),(0,J.jsx)(x,{side:`bottom`,children:`A comment is anchored to the whole change, so switch to All commits to write one.`})]}):null]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[ht.length>0?(0,J.jsxs)(_,{children:[(0,J.jsx)(m,{render:(0,J.jsx)(f,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":_t?`Expand all files`:`Collapse all files`,onClick:Ot}),children:_t?(0,J.jsx)(oe,{className:`size-3.5`}):(0,J.jsx)(le,{className:`size-3.5`})}),(0,J.jsx)(x,{side:`top`,children:_t?`Expand all files`:`Collapse all files`})]}):null,(0,J.jsxs)(Ie,{className:`shrink-0 gap-1`,size:`sm`,value:[je],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&Pe(t)},children:[(0,J.jsx)(Le,{"aria-label":`Stacked diff view`,value:`stacked`,variant:`ghost`,children:(0,J.jsx)(Oe,{className:`size-3.5`})}),(0,J.jsx)(Le,{"aria-label":`Split diff view`,value:`split`,variant:`ghost`,children:(0,J.jsx)(Ae,{className:`size-3.5`})})]}),(0,J.jsxs)(_,{children:[(0,J.jsx)(m,{render:(0,J.jsx)(Le,{"aria-label":N?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`ghost`,size:`sm`,pressed:N,onPressedChange:e=>{Re(!!e)}}),children:(0,J.jsx)(E,{className:`size-3.5`})}),(0,J.jsx)(x,{side:`top`,children:N?`Disable line wrapping`:`Enable line wrapping`})]})]})]}),Ut=e=>(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ht,(0,J.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`h-full overflow-auto`,children:e}),zt]})]});if(K.isPending&&W.length===0)return Ut((0,J.jsx)(Me,{label:`Loading pull request diff...`}));if(K.error&&W.length===0)return Ut((0,J.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:K.error}));let Wt=Z===null?at.flatMap(e=>e?.kind===`raw`?[e]:[]):[];if(X.length===0&&Wt.length>0)return Ut((0,J.jsx)(`div`,{className:`space-y-4 px-4 py-5`,children:Wt.map(e=>(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,J.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))}));if($.length===0&&Z===null)return Ut((0,J.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:H===null?`This pull request has no file changes.`:`This commit has no file changes.`}));let Gt=n.reviewThreads.filter(e=>!ft.has(e.id)),Kt=new Map;for(let e of Gt){let t=Kt.get(e.path);t?t.push(e):Kt.set(e.path,[e])}let qt=Wt.length===0?null:(0,J.jsx)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-5`,children:Wt.map(e=>(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,J.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))});return(0,J.jsx)(Ne,{children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ht,Kt.size>0?(0,J.jsxs)(ue,{className:`shrink-0 border-b border-border/60`,open:Ve,onOpenChange:He,children:[(0,J.jsx)(`h2`,{children:(0,J.jsxs)(pe,{className:`flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:Z===null?`Conversations not on the current diff`:`Conversations not on the diff loaded so far`}),(0,J.jsx)(ne,{"aria-hidden":!0,className:ee(`size-3.5 transition-transform`,Ve&&`rotate-90`)}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`tabular-nums`,children:Gt.length}),(0,J.jsx)(`span`,{className:`sr-only`,children:Gt.length===1?`1 conversation`:`${Gt.length} conversations`})]})}),(0,J.jsx)(fe,{children:(0,J.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-auto px-4 pb-3`,children:[...Kt].map(([e,t])=>(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(_,{children:[(0,J.jsx)(m,{render:(0,J.jsx)(`p`,{className:`truncate px-3 text-xs text-muted-foreground`,children:e})}),(0,J.jsx)(x,{side:`top`,children:e})]}),(0,J.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,J.jsxs)(`div`,{children:[e.line===null?null:(0,J.jsxs)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:[`Line `,e.line]}),Lt(e)]},e.id))})]},e))})})]}):null,(0,J.jsxs)(`div`,{className:`relative min-h-0 flex-1`,onClickCapture:e=>{let t=e.nativeEvent.composedPath?.()??[];for(let e of t)if(e instanceof HTMLElement){if(e instanceof HTMLButtonElement||e instanceof HTMLAnchorElement)return;if(e.hasAttribute(`data-diffs-header`)){let t=e.querySelector(`[data-title]`)?.textContent?.trim();if(t===void 0||t===``)return;let n=$.find(e=>k(e.fileDiff)===t);n!==void 0&&Dt(n.id);return}}},children:[(0,J.jsx)(ke,{className:`h-full overflow-auto [scrollbar-gutter:stable]`,items:$,selectedLines:ze,onSelectedLinesChange:P,options:Ft,renderCodeViewFooter:Mt,renderHeaderPrefix:Nt,renderHeaderMetadata:Pt,renderAnnotation:Rt,unsafeCSSExtra:xt}),zt]}),qt]})})}export{Tt as PullRequestCodeTab,Tt as default};
6
- //# sourceMappingURL=PullRequestCodeTab-Bxx0Vkdn.js.map