branch-lens 0.3.0 → 0.3.1

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 (62) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -1
  3. package/dist/cli.js +5620 -3272
  4. package/dist/cpuWorker.js +1988 -0
  5. package/dist/launcher.d.ts +68 -15
  6. package/dist/launcher.js +6966 -4617
  7. package/dist/web/assets/AiAnnotator-CCj1dKr0.js +1 -0
  8. package/dist/web/assets/ChronicleStage-Cznb0SLP.js +30 -0
  9. package/dist/web/assets/CodeDiffStage-BAkeoFAz.js +3 -0
  10. package/dist/web/assets/CodexSessionBindingFields-DkR0bGRW.js +1 -0
  11. package/dist/web/assets/CompareStage-6mAMGmE9.js +2 -0
  12. package/dist/web/assets/CompareStage-DMkd60zd.css +1 -0
  13. package/dist/web/assets/DoctorChecklist-cmvmLa4s.js +1 -0
  14. package/dist/web/assets/ExecutionTraceView-BuKMTJLz.js +1 -0
  15. package/dist/web/assets/LiquidSelect-BcHivJrw.js +1 -0
  16. package/dist/web/assets/LogDrawer-hywJ_5f2.js +1 -0
  17. package/dist/web/assets/{PrDraftModal-DpkvQrsw.js → PrDraftModal-CKdIoZTF.js} +2 -12
  18. package/dist/web/assets/ResponsiveMatrixStage-IZfS6JC4.js +1 -0
  19. package/dist/web/assets/RouteBar-CbnzrFM4.js +1 -0
  20. package/dist/web/assets/SafeMarkdownBody-DAg3yHJ5.js +1 -0
  21. package/dist/web/assets/SettingsModal-CfMz0_4F.js +4 -0
  22. package/dist/web/assets/{TaskComposer-EPlw68x5.js → TaskComposer-CO8tCqFg.js} +5 -5
  23. package/dist/web/assets/TaskPanel--8Ima6hX.js +5 -0
  24. package/dist/web/assets/VerificationSummaryCard-D5fnYeAl.js +1 -0
  25. package/dist/web/assets/VerificationView-OYxRYOMD.js +1 -0
  26. package/dist/web/assets/WelcomeDoctorView-DCmfWMhg.js +1 -0
  27. package/dist/web/assets/annotate-Cnu9ugkR.css +1 -0
  28. package/dist/web/assets/doctor-BvSbLVK8.css +1 -0
  29. package/dist/web/assets/index-B76NgI6o.css +1 -0
  30. package/dist/web/assets/index-CuRBE0Be.js +3 -0
  31. package/dist/web/assets/logs-_ws1o3oK.css +1 -0
  32. package/dist/web/assets/pickedElement-DWJDcr9q.js +1 -0
  33. package/dist/web/assets/settings-DaDpE3K8.css +1 -0
  34. package/dist/web/assets/stageCache-nD7q31wP.js +1 -0
  35. package/dist/web/assets/tasks-BYC2JuuF.css +1 -0
  36. package/dist/web/assets/vendor-icons-BeN0on9X.js +371 -0
  37. package/dist/web/assets/vendor-markdown-COdlM-u6.js +14 -0
  38. package/dist/web/assets/vendor-react-CIotE-6Q.js +49 -0
  39. package/dist/web/index.html +9 -2
  40. package/package.json +1 -1
  41. package/dist/web/assets/AiAnnotator-zRRz7Hd_.js +0 -21
  42. package/dist/web/assets/ChronicleStage-DU21HBDf.js +0 -30
  43. package/dist/web/assets/CodeDiffStage-DAhgBZQK.js +0 -23
  44. package/dist/web/assets/CodexSessionBindingFields-DiO2jbce.js +0 -1
  45. package/dist/web/assets/CompareStage-BJ8Jwxc8.js +0 -37
  46. package/dist/web/assets/DoctorChecklist-C6zhApVB.js +0 -11
  47. package/dist/web/assets/ExecutionTraceView-BJm89dCg.js +0 -21
  48. package/dist/web/assets/ResponsiveMatrixStage-Df2JDBnc.js +0 -6
  49. package/dist/web/assets/RouteBar-DgHUPTd-.js +0 -1
  50. package/dist/web/assets/SafeMarkdownBody-CqB1wBws.js +0 -14
  51. package/dist/web/assets/SettingsModal-BUP_V44u.js +0 -9
  52. package/dist/web/assets/VerificationView-CQZlUjOa.js +0 -1
  53. package/dist/web/assets/WelcomeDoctorView-Cdemm1Gq.js +0 -6
  54. package/dist/web/assets/book-open-J84boHt9.js +0 -6
  55. package/dist/web/assets/chevron-up-BNxyonTB.js +0 -6
  56. package/dist/web/assets/external-link-BOTi_FMk.js +0 -6
  57. package/dist/web/assets/git-commit-horizontal-fzBJ5V7a.js +0 -11
  58. package/dist/web/assets/index-DOHn8ygK.js +0 -254
  59. package/dist/web/assets/index-_5gNstnt.css +0 -1
  60. package/dist/web/assets/info-kubeg88y.js +0 -6
  61. package/dist/web/assets/pickedElement-p10cew5p.js +0 -11
  62. package/dist/web/assets/search-CZutG0ij.js +0 -6
@@ -0,0 +1 @@
1
+ import{j as e,r as h,a as Ge}from"./vendor-react-CIotE-6Q.js";import{t as Fe,s as de,a as qe,u as Ve,v as ye,x as Te}from"./index-CuRBE0Be.js";import{L as Le}from"./LiquidSelect-BcHivJrw.js";import{R as Ze}from"./RouteBar-CbnzrFM4.js";import{b as Xe,C as Je,_ as Qe,g as Oe,$ as et,e as ke,a0 as tt,a1 as nt,a2 as st,F as at}from"./vendor-icons-BeN0on9X.js";const Ye="branch-lens:annotate:route-bar-collapsed";function ot(){try{const t=window.localStorage.getItem(Ye);return t==="1"||t==="true"}catch{return!1}}function lt(t){try{window.localStorage.setItem(Ye,t?"1":"0")}catch{}}function it(t){return!!(t.noLogin&&/\/design-review\//i.test(t.route))}const ve=6,le=10,rt=({route:t,compareTargets:n,onRouteChange:p,onCollapse:v})=>{const[o,b]=h.useState(!1),[$,d]=h.useState(null),S=h.useRef(null),y=h.useRef(null),i=h.useRef(null),a=n.find(s=>s.route===t)??null;h.useEffect(()=>{n.length===0&&o&&b(!1)},[n.length,o]);const z=h.useCallback(()=>{var ae;const s=y.current;if(!s)return null;const m=s.getBoundingClientRect(),r=(ae=S.current)==null?void 0:ae.getBoundingClientRect(),g=r&&r.width>0?Math.min(window.innerWidth||r.width,r.width):window.innerWidth||1440,w=window.innerHeight||900,C=Math.max(240,Math.min(440,g-le*2)),L=i.current,Y=Math.min(360,n.length*60+42),I=L&&L.offsetHeight>0?Math.ceil(L.offsetHeight):Y,H=r&&r.width>0?Math.max(le,r.left+le):le,G=r&&r.width>0?Math.min(window.innerWidth||r.right,r.right)-le:g-le;let D=m.left;D+C>G&&(D=G-C),D=Math.max(H,D);const R=w-m.bottom-ve-le,q=m.top-ve-le,F=R<I&&q>R,A=Math.max(160,Math.min(372,F?q:R)),se=Math.min(I,A),O=F?Math.max(le,m.top-ve-se):Math.max(le,m.bottom+ve),U=m.left+m.width/2,ee=Math.max(20,Math.min(C-20,Math.round(U-D)));return{left:Math.round(D),top:Math.round(O),width:Math.round(C),maxListHeight:Math.max(120,Math.min(320,Math.round(A-40))),placement:F?"top":"bottom",originX:ee}},[n.length]);h.useLayoutEffect(()=>{if(!o)return;const s=()=>{const m=z();m&&d(m)};return s(),window.addEventListener("resize",s,{passive:!0}),()=>window.removeEventListener("resize",s)},[o,z]),h.useEffect(()=>{if(!o)return;const s=g=>{var C,L;const w=g.target;w&&((C=y.current)!=null&&C.contains(w)||(L=i.current)!=null&&L.contains(w)||b(!1))},m=g=>{var w;g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),b(!1),(w=y.current)==null||w.focus())},r=g=>{var w;g.target instanceof Node&&((w=i.current)!=null&&w.contains(g.target))||b(!1)};return document.addEventListener("mousedown",s,!0),document.addEventListener("pointerdown",s,!0),document.addEventListener("keydown",m,!0),window.addEventListener("scroll",r,{passive:!0,capture:!0}),()=>{document.removeEventListener("mousedown",s,!0),document.removeEventListener("pointerdown",s,!0),document.removeEventListener("keydown",m,!0),window.removeEventListener("scroll",r,!0)}},[o]);const X=o&&$&&typeof document<"u"?Ge.createPortal(e.jsxs("div",{ref:i,"data-testid":"annotate-changed-pages-popover","data-placement":$.placement,className:"bl-annotate-pages-popover",style:{left:`${$.left}px`,top:`${$.top}px`,width:`${$.width}px`,transformOrigin:`${$.originX}px ${$.placement==="top"?"bottom":"top"}`},onPointerDown:s=>s.stopPropagation(),onMouseDown:s=>s.stopPropagation(),onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"px-3 py-2 flex items-center justify-between gap-2 text-[11px]",style:{borderBottom:"1px solid var(--hair)"},children:[e.jsx("span",{className:"caps",children:"改动页面列表"}),e.jsxs("span",{className:"mono",style:{color:"var(--faint)"},children:["共 ",n.length," 项"]})]}),e.jsx("div",{role:"listbox","aria-label":"全部改动页面",className:"overflow-y-auto p-1.5 space-y-0.5",style:{maxHeight:`${$.maxListHeight}px`},children:n.map(s=>{const m=t===s.route,r=it(s);return e.jsxs("button",{type:"button",role:"option","aria-selected":m,"data-testid":"annotate-changed-page-option","data-active":m?"true":void 0,onClick:()=>{p(s.route),b(!1)},className:"bl-annotate-page-option w-full text-left",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-[12.5px] font-medium truncate",children:s.label}),r&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded shrink-0 font-medium leading-none",style:{background:"var(--accent)",color:"#fff"},children:"免登录"})]}),m&&e.jsx(Je,{size:13,className:"shrink-0",style:{color:"var(--accent)"},"aria-hidden":"true"})]}),e.jsx("div",{className:"mono text-[11px] truncate mt-0.5",style:{color:m?"var(--accent)":"var(--muted)"},title:s.route,children:s.route}),s.reason&&e.jsx("div",{className:"text-[11px] truncate mt-0.5",style:{color:"var(--faint)"},title:s.reason,children:s.reason})]},s.route)})})]}),document.body):null;return e.jsxs("div",{ref:S,"data-testid":"annotate-route-bar",className:"bl-annotate-routebar px-4 sm:px-6 h-10 shrink-0 flex items-center gap-2.5 flex-nowrap text-xs relative z-30",children:[e.jsx(Ze,{route:t,onRouteApply:p}),n.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-4 w-px shrink-0",style:{background:"var(--hair-strong)"},"aria-hidden":"true"}),e.jsxs("button",{ref:y,type:"button","data-testid":"annotate-changed-pages-toggle","aria-expanded":o,"aria-haspopup":"listbox","data-open":o?"true":void 0,onClick:()=>{o?b(!1):(d(z()),b(!0))},title:a?`当前:${a.label} (${a.route}) · 点击查看全部 ${n.length} 个改动页面`:`点击查看并切换全部 ${n.length} 个改动页面`,className:"bl-annotate-pages-trigger min-w-0 max-w-full",children:[e.jsxs("span",{className:"shrink-0 font-medium",children:["改动页面(",n.length,")"]}),a&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-45 shrink-0","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"truncate font-semibold",style:{color:"var(--accent)"},children:a.label})]}),e.jsx(Xe,{size:13,className:`shrink-0 opacity-70 transition-transform duration-200 ${o?"rotate-180":""}`})]}),X]}),e.jsxs("button",{type:"button","data-testid":"annotate-route-bar-collapse","aria-label":"收起路由栏",title:"收起路由与改动页面栏,释放更多画布高度",onClick:v,className:"bl-annotate-collapse-btn ml-auto shrink-0 inline-flex items-center gap-1",children:[e.jsx("span",{children:"收起"}),e.jsx(Qe,{size:13})]})]})},ct=({route:t,changedPagesCount:n,onExpand:p})=>e.jsxs("button",{type:"button","data-testid":"annotate-route-bar-expand","aria-label":"展开路由与改动页面栏",title:`${t} · 点击展开路由与改动页面栏`,onClick:p,className:"bl-annotate-route-pill inline-flex items-center gap-1 max-w-[152px] shrink-0",children:[e.jsx("span",{className:"mono text-[11px] truncate",children:t}),n>0&&e.jsxs("span",{className:"bl-annotate-route-pill-count mono shrink-0",children:[n," 页"]}),e.jsx(Xe,{size:11.5,className:"shrink-0 opacity-70"})]});function Be(t,n){if(t.normBox&&Number.isFinite(t.normBox.width)&&Number.isFinite(t.normBox.height)&&t.normBox.width>0&&t.normBox.height>0)return t.normBox;const p=(n==null?void 0:n.width)||1280,v=(n==null?void 0:n.height)||800;return{x:t.box.x/p,y:t.box.y/v,width:t.box.width/p,height:t.box.height/v}}const ze=({regions:t,showBoxes:n,effectiveMode:p,baseImageUrl:v,imageSize:o,verificationOverlay:b,drawMode:$=!1,selectedId:d,hoveredId:S,onSelectRegion:y,onHoverRegion:i})=>{if(!n||p==="heatmap")return null;if(b){const a=new Set(b.hitRegions),z=(b.otherRouteEffects??[]).map(s=>`[${s.route}]`),X=b.sideEffects.filter(s=>!z.some(m=>s.title.startsWith(m)));return e.jsxs(e.Fragment,{children:[b.targetRegions.map(s=>{const m=a.has(s.id),r=Be(s,o),g=String(s.id).padStart(2,"0"),w=r.y<.05,C=m?"#16a34a":"#d97706",L=m?"rgba(22, 163, 74, 0.14)":"rgba(217, 119, 6, 0.1)";return e.jsx("div",{"data-verify-box":m?"hit":"missed","data-border-style":"solid",style:{left:`${r.x*100}%`,top:`${r.y*100}%`,width:`${r.width*100}%`,height:`${r.height*100}%`,border:`2px solid ${C}`,background:L},className:"bl-redbox absolute pointer-events-none z-20","aria-label":`原批注区域 ${g}(${m?"已命中":"未命中"}):${s.title}`,children:e.jsxs("span",{className:"bl-redbox-tag absolute mono text-[10.5px] font-semibold px-1.5 leading-[18px] text-white whitespace-nowrap",style:{background:C,...w?{bottom:-19,left:-1}:{top:-19,left:-1}},children:["目标 ",g," · ",m?"已命中":"未命中"]})},`target-${s.id}`)}),X.map((s,m)=>{const r=d===s.id,g=S===s.id,w=Be(s,o),C=String(s.id).padStart(2,"0"),L=w.y<.05;return e.jsx("button",{type:"button","data-verify-box":"side-effect","data-border-style":"dashed",onClick:()=>y(s.id),onMouseEnter:()=>i(s.id),onMouseLeave:()=>i(null),style:{left:`${w.x*100}%`,top:`${w.y*100}%`,width:`${w.width*100}%`,height:`${w.height*100}%`,border:`${r?2.5:2}px dashed #dc2626`,background:r||g?"rgba(220, 38, 38, 0.2)":"rgba(220, 38, 38, 0.1)"},className:`bl-redbox absolute cursor-pointer text-left transition-colors ${r||g?"z-30":"z-20"}`,"aria-label":`副作用区域 ${C}:${s.title}`,children:e.jsxs("span",{className:"bl-redbox-tag absolute mono text-[10.5px] font-semibold px-1.5 leading-[18px] text-white whitespace-nowrap pointer-events-none",style:{background:"#dc2626",...L?{bottom:-19,left:-1}:{top:-19,left:-1}},children:["副作用 ",C]})},`side-effect-${s.id}-${m}`)})]})}return e.jsx(e.Fragment,{children:t.map(a=>{const z=d===a.id,X=S===a.id,s=Fe(a),m=String(a.id).padStart(2,"0"),r=a.title.trim()||`未命名批注 #${a.id}`,g=a.normBox.y<.05,w=a.normBox.x+a.normBox.width>.62,C=a.normBox.y+a.normBox.height>.84,L=a.category==="删除",Y=L&&p==="annotated"&&!!v,I=s?"var(--accent)":"var(--redline, var(--accent))",H=s?"var(--accent-soft)":"var(--redline-soft, var(--accent-soft))",G=g?C?{top:2,right:2}:{bottom:-19,left:-1}:{top:-19,left:-1},D={background:"var(--ink)",color:"var(--bg)",border:"1px solid var(--border, rgba(15, 23, 42, 0.22))",boxShadow:"0 4px 12px rgba(15, 23, 42, 0.24), 0 1px 3px rgba(15, 23, 42, 0.14), inset 0 0 0 0.5px rgba(255, 255, 255, 0.14)"},R=g&&C?{...D,top:24,right:2}:{...D,right:w?0:void 0,left:w?void 0:0,top:C?-30:void 0,bottom:C?void 0:g?-46:-30};return e.jsxs("button",{type:"button","data-region-id":a.id,"data-region-source":s?"manual":"auto",onClick:()=>y(a.id),onMouseEnter:()=>i(a.id),onMouseLeave:()=>i(null),style:{left:`${a.normBox.x*100}%`,top:`${a.normBox.y*100}%`,width:`${a.normBox.width*100}%`,height:`${a.normBox.height*100}%`,border:`${z?2:1.5}px ${L||s?"dashed":"solid"} ${I}`,background:z||X?H:"transparent"},className:`bl-redbox absolute text-left transition-colors ${$?"pointer-events-none":"cursor-pointer"} ${z||X?"z-20":"z-10"}`,"aria-label":`${s?"手动批注":"批注"} ${m}:${r}`,children:[Y&&a.normBox.width>0&&a.normBox.height>0&&e.jsxs("span",{"aria-hidden":"true",className:"absolute inset-0 overflow-hidden pointer-events-none",style:{borderRadius:"inherit"},children:[e.jsx("img",{src:de(v),alt:"",draggable:!1,style:{position:"absolute",left:`${-(a.normBox.x/a.normBox.width)*100}%`,top:`${-(a.normBox.y/a.normBox.height)*100}%`,width:`${100/a.normBox.width}%`,height:`${100/a.normBox.height}%`,maxWidth:"none",opacity:z||X?.44:.26,filter:"grayscale(30%)"}}),e.jsx("span",{className:"absolute inset-0",style:{background:"repeating-linear-gradient(-45deg, rgba(215, 0, 21, 0.08) 0 6px, transparent 6px 12px)"}})]}),e.jsxs("span",{className:"bl-redbox-tag absolute mono text-[10.5px] font-semibold px-1.5 leading-[18px] text-white pointer-events-none whitespace-nowrap",style:{background:I,...G},children:[s?`手动 ${m}`:m,L?" · 已移除":""]}),(z||X)&&e.jsxs("div",{"data-testid":`region-tooltip-${a.id}`,className:"bl-redbox-tag absolute whitespace-nowrap max-w-[260px] truncate px-2.5 py-1 text-xs font-medium pointer-events-none",style:R,children:[e.jsx("span",{className:"mono mr-1.5 opacity-75",children:m}),r]})]},a.id)})})};function Ne(t){return Math.max(0,Math.min(1,t))}const dt=({branches:t,baseRef:n,targetRef:p,route:v,result:o,verificationOverlay:b,chromeMissing:$=!1,drawMode:d=!1,loading:S,progressText:y,error:i,effectiveMode:a,showBoxes:z,sliderPos:X,selectedId:s,hoveredId:m,stageRef:r,onDragSliderStart:g,onCreateManualRegion:w,onSelectRegion:C,onHoverRegion:L,onTargetChange:Y,onRunAnnotate:I,onOpenEnvSettings:H,onBackToLiveCompare:G,onBackToTree:D})=>{const[R,q]=h.useState(null),F=h.useRef(null),A=h.useRef(null),se=h.useRef(null),O=R!==null,U=!!(d&&o&&a!=="slider"&&a!=="heatmap"&&!b&&w);h.useEffect(()=>{U||(F.current=null,A.current=null,q(null))},[U]),h.useEffect(()=>{if(!O||!o||!w)return;let N=null,B=null;const oe=(c,u)=>{var ie;const j=F.current,f=A.current,P=f&&f.width>0&&f.height>0?f:((ie=r.current)==null?void 0:ie.getBoundingClientRect())??null;if(!j||!P||P.width<=0||P.height<=0)return;A.current=P;const K=Math.max(0,Math.min(P.width,c-P.left)),E=Math.max(0,Math.min(P.height,u-P.top)),k={...j,curX:K,curY:E,width:P.width,height:P.height};F.current=k;const _=se.current;_?(_.style.left=`${Math.min(k.startX,k.curX)/k.width*100}%`,_.style.top=`${Math.min(k.startY,k.curY)/k.height*100}%`,_.style.width=`${Math.abs(k.curX-k.startX)/k.width*100}%`,_.style.height=`${Math.abs(k.curY-k.startY)/k.height*100}%`):q(k)},J=c=>{B={clientX:c.clientX,clientY:c.clientY},N===null&&(N=window.requestAnimationFrame(()=>{if(N=null,B){const u=B;B=null,oe(u.clientX,u.clientY)}}))},te=()=>{var c;A.current=((c=r.current)==null?void 0:c.getBoundingClientRect())??null},V=c=>{var me,T,fe;N!==null&&(window.cancelAnimationFrame(N),N=null),B=null;const u=F.current,j=A.current;if(F.current=null,A.current=null,q(null),!u)return;const f=j&&j.width>0&&j.height>0?j:((me=r.current)==null?void 0:me.getBoundingClientRect())??null,P=f&&f.width>0?f.width:u.width,K=f&&f.height>0?f.height:u.height,E=f&&f.width>0?Math.max(0,Math.min(f.width,c.clientX-f.left)):u.curX,k=f&&f.height>0?Math.max(0,Math.min(f.height,c.clientY-f.top)):u.curY,_=Math.abs(E-u.startX),ie=Math.abs(k-u.startY);if(_<8||ie<8||P<=0||K<=0)return;const xe=Math.min(u.startX,E),W=Math.min(u.startY,k),ne={x:Ne(xe/P),y:Ne(W/K),width:Ne(_/P),height:Ne(ie/K)},ue=o.imageSize.width||((T=o.viewport)==null?void 0:T.width)||1280,be=o.imageSize.height||((fe=o.viewport)==null?void 0:fe.height)||800,ge={x:Math.round(ne.x*ue),y:Math.round(ne.y*be),width:Math.max(1,Math.round(ne.width*ue)),height:Math.max(1,Math.round(ne.height*be))};w({box:ge,normBox:ne})};return window.addEventListener("pointermove",J),window.addEventListener("mousemove",J),window.addEventListener("pointerup",V),window.addEventListener("mouseup",V),window.addEventListener("resize",te),()=>{N!==null&&window.cancelAnimationFrame(N),window.removeEventListener("pointermove",J),window.removeEventListener("mousemove",J),window.removeEventListener("pointerup",V),window.removeEventListener("mouseup",V),window.removeEventListener("resize",te)}},[O,o,r,w]);const ee=N=>{var V;if(!U||N.button!==0||F.current)return;const B=(V=r.current)==null?void 0:V.getBoundingClientRect();if(!B||B.width<=0||B.height<=0)return;N.preventDefault(),A.current=B;const oe=Math.max(0,Math.min(B.width,N.clientX-B.left)),J=Math.max(0,Math.min(B.height,N.clientY-B.top)),te={startX:oe,startY:J,curX:oe,curY:J,width:B.width,height:B.height};F.current=te,q(te)},ae=R&&R.width>0&&R.height>0?{left:`${Math.min(R.startX,R.curX)/R.width*100}%`,top:`${Math.min(R.startY,R.curY)/R.height*100}%`,width:`${Math.abs(R.curX-R.startX)/R.width*100}%`,height:`${Math.abs(R.curY-R.startY)/R.height*100}%`}:null;return e.jsx("div",{className:"relative z-0 flex-1 min-w-0 h-full overflow-auto p-4 md:p-6 flex flex-col items-center",children:S?e.jsxs("div",{className:"bl-empty-card max-w-md w-full my-auto text-center flex flex-col items-center",children:[e.jsx("div",{className:"bl-spinner mb-4"}),e.jsx("div",{className:"caps mb-1.5",style:{color:"var(--accent)"},children:"ANALYZING"}),e.jsx("div",{className:"text-[18px] font-semibold mb-2",children:"正在校图与生成批注"}),e.jsx("p",{className:"text-[13px] mono",style:{color:"var(--muted)"},children:y||"正在抓取双版本画面…"})]}):i?e.jsxs("div",{className:"bl-empty-card max-w-md w-full my-auto",children:[e.jsx("div",{className:"caps mb-2",style:{color:"var(--redline, var(--accent))"},children:"■ 分析失败"}),e.jsx("p",{className:"text-[13px] mb-5 break-all",style:{color:"var(--muted)"},children:i}),e.jsxs("div",{className:"flex items-center gap-4 text-[13px]",children:[e.jsx("button",{type:"button",onClick:()=>I(!0),className:"sheet-btn sheet-btn-primary",children:"重试分析 →"}),e.jsx("button",{type:"button",onClick:G,className:"hover:underline underline-offset-4",style:{color:"var(--muted)"},children:"返回实时对比"})]})]}):o?e.jsxs("div",{className:"w-full max-w-[1280px] my-auto flex flex-col",children:[e.jsxs("div",{className:"w-full flex items-baseline justify-between mb-2.5 text-[11px] flex-wrap gap-2",children:[e.jsx("span",{className:"mono",style:{color:a==="original"?"var(--accent)":"var(--muted)"},children:a==="original"?`原版 · ${o.baseRef}`:a==="heatmap"?"像素差异热力图":a==="slider"?`左:${o.baseRef} / 右:${o.targetRef}`:`新版 · ${o.targetRef}`}),b&&e.jsxs("div",{className:"flex items-center gap-3 text-[11px] flex-wrap","data-verify-legend":"true",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"inline-block w-3 h-2",style:{border:"2px solid #16a34a",background:"rgba(22, 163, 74, 0.14)"}}),e.jsx("span",{children:"命中原批注"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"inline-block w-3 h-2",style:{border:"2px solid #d97706",background:"rgba(217, 119, 6, 0.1)"}}),e.jsx("span",{children:"未命中原批注"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"inline-block w-3 h-2",style:{border:"2px dashed #dc2626",background:"rgba(220, 38, 38, 0.1)"}}),e.jsx("span",{children:"副作用区域"})]})]}),e.jsxs("span",{className:"mono",style:{color:"var(--faint)"},children:[o.imageSize.width,"×",o.imageSize.height," · 差异 ",(o.totalDiffRatio*100).toFixed(2),"%"]})]}),e.jsxs("div",{ref:r,"data-testid":"annotator-stage","data-draw-mode":U?"true":void 0,onPointerDown:ee,onMouseDown:ee,className:`bl-frame bl-frame-primary bl-frame-body relative w-full overflow-hidden bg-white select-none ${U?"cursor-crosshair":""}`,style:{aspectRatio:`${o.imageSize.width} / ${o.imageSize.height}`,borderColor:a==="original"?"var(--accent)":void 0,cursor:U?"crosshair":void 0,"--bl-slider-pos":`${X}%`},children:[a==="slider"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:de(o.baseImageUrl),alt:"原版截图",draggable:!1,className:"absolute inset-0 w-full h-full object-contain"}),e.jsx("div",{className:"absolute inset-0",style:{clipPath:"inset(0 0 0 var(--bl-slider-pos, 50%))"},children:e.jsx("img",{src:de(o.targetImageUrl),alt:"新版截图",draggable:!1,className:"w-full h-full object-contain"})}),e.jsx(ze,{regions:o.regions,showBoxes:z,effectiveMode:a,baseImageUrl:o.baseImageUrl,imageSize:o.imageSize,verificationOverlay:b,selectedId:s,hoveredId:m,onSelectRegion:C,onHoverRegion:L}),e.jsx("div",{"data-testid":"annotator-slider-handle",onPointerDown:N=>{N.preventDefault(),g()},onMouseDown:N=>{N.preventDefault(),g()},style:{left:"var(--bl-slider-pos, 50%)",background:"var(--accent)"},className:"absolute top-0 bottom-0 w-[2px] -ml-[1px] cursor-ew-resize z-30",children:e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2 w-6 h-10 flex items-center justify-center mono text-[11px] text-white",style:{background:"var(--accent)"},children:"⇄"})})]}):a==="heatmap"?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:de(o.baseImageUrl),alt:"差异底图参考",draggable:!1,className:"w-full h-full object-contain block opacity-25 grayscale"}),e.jsx("img",{src:de(o.diffImageUrl),alt:"像素差异热力图",draggable:!1,className:"absolute inset-0 w-full h-full object-contain block pointer-events-none"})]}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:de(o.targetImageUrl),alt:"新版截图","data-testid":"annotator-target-image","data-visible":a!=="original"?"true":"false","aria-hidden":a==="original"||void 0,draggable:!1,className:"w-full h-full object-contain block",style:{opacity:a==="original"?0:1,visibility:a==="original"?"hidden":"visible"}}),e.jsx("img",{src:de(o.baseImageUrl),alt:"原版截图","data-testid":"annotator-base-image","data-visible":a==="original"?"true":"false","aria-hidden":a!=="original"||void 0,draggable:!1,className:"absolute inset-0 w-full h-full object-contain block pointer-events-none",style:{opacity:a==="original"?1:0,visibility:a==="original"?"visible":"hidden"}}),e.jsx(ze,{regions:o.regions,showBoxes:z,effectiveMode:a,baseImageUrl:o.baseImageUrl,imageSize:o.imageSize,verificationOverlay:b,drawMode:U,selectedId:s,hoveredId:m,onSelectRegion:C,onHoverRegion:L})]}),ae&&e.jsx("div",{ref:se,"data-testid":"manual-draw-preview",className:"absolute pointer-events-none z-40",style:{...ae,border:"2px dashed var(--accent)",background:"var(--accent-soft)"}})]})]}):e.jsxs("div",{className:"bl-empty-card max-w-lg w-full my-auto",children:[e.jsx("div",{className:"caps mb-2",children:"REDLINE VISUAL DIFF"}),e.jsx("h2",{className:"text-[28px] font-semibold tracking-tight leading-tight",children:"红框视觉校图"}),e.jsxs("p",{className:"text-[13.5px] leading-relaxed mt-3 mb-5",style:{color:"var(--muted)"},children:["自动抓取 ",e.jsx("span",{className:"mono font-medium",style:{color:"var(--ink)"},children:n||"原版"})," 与"," ",e.jsx("span",{className:"mono font-medium",style:{color:"var(--accent)"},children:p||"待选目标分支"})," 在路由"," ",e.jsx("span",{className:"mono",children:v})," 的真实渲染画面,精准框选每处视觉变动并支持一键闪看原版。"]}),p?$?e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("button",{type:"button",disabled:!0,className:"sheet-btn disabled:opacity-45",title:"需先安装或配置本机 Chrome 后才能运行红框截图批注",children:"开始红框批注 →"}),e.jsx("button",{type:"button",onClick:H,"data-testid":"annotate-open-chrome-guide",className:"sheet-btn sheet-btn-accent",children:"查看本机 Chrome 配置 →"})]}):e.jsx("button",{type:"button",onClick:()=>I(!1),disabled:!n||!p,className:"sheet-btn sheet-btn-primary",children:"开始红框批注 →"}):e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium mb-2.5",style:{color:"var(--faint)"},children:"快速点选一个目标分支立即开始分析:"}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:t.filter(N=>N.ref!==n&&!N.isBase).slice(0,6).map(N=>e.jsx("button",{type:"button",onClick:()=>Y(N.ref),className:"bl-pill-action text-[13px] font-medium",children:N.label},N.ref))}),e.jsx("button",{type:"button",onClick:D,className:"sheet-link text-[13px]",children:"← 返回分支树挑选"})]})]})})},ht=({baseRef:t,targetRef:n,files:p,onOpenFileDiff:v})=>e.jsx("div",{children:p.map((o,b)=>e.jsxs("button",{type:"button",onClick:()=>v(t,n,o.path),className:"w-full text-left py-2.5 flex items-baseline justify-between gap-2 group",style:{borderBottom:"1px solid var(--hair)"},children:[e.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[e.jsx("span",{className:"mono text-[10.5px]",style:{color:"var(--faint)"},children:String(b+1).padStart(2,"0")}),e.jsx("span",{className:"mono text-[11.5px] truncate group-hover:underline underline-offset-4",children:o.path})]}),e.jsxs("span",{className:"mono text-[10px] shrink-0",style:{color:"var(--muted)"},children:["+",o.additions," / -",o.deletions]})]},o.path))}),xt=({result:t,selectedId:n,checkedIds:p=[],onToggleCheck:v,onUpdateManualRegion:o,onDeleteManualRegion:b,onToggleSelect:$,onHoverRegion:d,onOpenFileDiff:S,onHoldingOriginalChange:y})=>t.regions.length===0?e.jsx("div",{className:"py-12 text-xs leading-relaxed",style:{color:"var(--muted)"},children:"两版本画面一致,无视觉差异。可点击上方「手动拉框」直接在画面任意位置框选并填写修改意见。"}):e.jsx(e.Fragment,{children:t.regions.map(i=>{const a=n===i.id,z=p.includes(i.id),X=Fe(i),s=String(i.id).padStart(2,"0"),m=i.title.trim()||`未命名批注 #${i.id}`;return e.jsxs("div",{"data-region-item":i.id,"data-region-source":X?"manual":"auto",onMouseEnter:()=>d(i.id),onMouseLeave:()=>d(null),style:{borderBottom:"1px solid var(--hair)"},className:"py-3",children:[e.jsxs("div",{className:"w-full flex items-center justify-between gap-2",children:[v&&e.jsx("input",{type:"checkbox",checked:z,onChange:()=>v(i.id),"aria-label":`选择区域 ${i.id}:${m}`,className:"shrink-0 cursor-pointer",style:{accentColor:"var(--accent)"}}),e.jsxs("button",{type:"button",onClick:()=>$(i.id),className:"flex-1 min-w-0 text-left flex items-baseline justify-between gap-2 group",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5 min-w-0",children:[e.jsx("span",{className:"mono text-[11px] shrink-0",style:{color:a||z?"var(--accent)":"var(--faint)"},children:s}),X&&e.jsx("span",{className:"mono text-[9.5px] font-semibold px-1.5 py-0.2 rounded shrink-0",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:"手动"}),e.jsx("span",{className:"text-[13px] truncate group-hover:underline underline-offset-4",style:{fontWeight:a?600:400},children:m})]}),e.jsx("span",{className:"mono text-[10px] shrink-0",style:{color:"var(--faint)"},children:X?"手动拉框":i.category})]}),X&&b&&e.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),b(i.id)},"aria-label":`删除手动批注 ${s}`,title:"删除这条手动批注",className:"p-1 rounded opacity-60 hover:opacity-100 transition-opacity shrink-0",style:{color:"var(--diff-del-ink, var(--redline, #ef4444))"},children:e.jsx(Oe,{size:12})})]}),a&&e.jsxs("div",{className:"mt-2.5 pt-2.5 pl-[26px] space-y-2.5 text-xs",style:{borderTop:"1px dashed var(--hair)"},children:[X&&o?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1 text-[10px]",htmlFor:`manual-region-title-${i.id}`,children:"批注标题"}),e.jsx("input",{id:`manual-region-title-${i.id}`,type:"text","aria-label":`编辑批注 ${s} 标题`,value:i.title,onChange:r=>o(i.id,{title:r.target.value}),onKeyDown:r=>{r.code==="Space"&&r.stopPropagation()},placeholder:"如:顶部主按钮间距过挤",className:"sheet-input w-full h-7 text-xs"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"caps block mb-1 text-[10px]",htmlFor:`manual-region-desc-${i.id}`,children:"修改意见"}),e.jsx("textarea",{id:`manual-region-desc-${i.id}`,rows:3,"aria-label":`编辑批注 ${s} 修改意见`,value:i.description,onChange:r=>o(i.id,{description:r.target.value}),onKeyDown:r=>{r.code==="Space"&&r.stopPropagation()},placeholder:"写下想让 Codex 如何修改这处界面…",className:"w-full p-2 text-xs leading-relaxed rounded-lg outline-none resize-y",style:{background:"var(--bg)",border:"1px solid var(--hair-strong)",color:"var(--ink)"}})]}),e.jsxs("div",{className:"mono text-[10.5px]",style:{color:"var(--faint)"},children:["选区坐标:",i.box.x,", ",i.box.y," · ",i.box.width,"×",i.box.height,"px"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"leading-relaxed",style:{color:"var(--muted)"},children:i.description}),(i.beforeDesc||i.afterDesc)&&e.jsxs("blockquote",{className:"pl-3 space-y-1 text-[11.5px]",style:{borderLeft:"2px solid var(--accent)"},children:[i.beforeDesc&&e.jsxs("div",{style:{color:"var(--muted)"},children:[e.jsx("span",{className:"caps mr-2",children:"原版"}),i.beforeDesc]}),i.afterDesc&&e.jsxs("div",{children:[e.jsx("span",{className:"caps mr-2",style:{color:"var(--accent)"},children:"新版"}),i.afterDesc]})]})]}),e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2 pt-1 text-[11px]",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:i.relatedFiles.slice(0,3).map(r=>e.jsxs("button",{type:"button",onClick:()=>S(t.baseRef,t.targetRef,r),className:"sheet-link mono text-[11px]",children:[r.split("/").pop()," →"]},r))}),e.jsx("button",{type:"button",onMouseDown:()=>y(!0),onMouseUp:()=>y(!1),onMouseLeave:()=>y(!1),className:"hover:underline underline-offset-4",style:{color:"var(--accent)"},children:"按住看原版"})]})]})]},i.id)})}),pe="var(--diff-del-ink, var(--redline, #ef4444))",he=8;function Pe(t,n,p,v,o,b){if(p<=0||v<=0)return{x:Math.round(t),y:Math.round(n)};const $=Math.max(he,p-o-he),d=Math.max(he,v-b-he);return{x:Math.round(Math.max(he,Math.min($,t))),y:Math.round(Math.max(he,Math.min(d,n)))}}function De(t){return!!(t!=null&&t.closest("button, a, input, select, textarea"))}const mt=({result:t,verificationOverlay:n,viewportRef:p,collapsed:v,onCollapsedChange:o,rightTab:b,selectedId:$,checkedIds:d=[],onToggleCheck:S,onDispatchToCodex:y,onUpdateManualRegion:i,onDeleteManualRegion:a,onRightTabChange:z,onToggleSelect:X,onHoverRegion:s,onOpenFileDiff:m,onHoldingOriginalChange:r})=>{const[g,w]=h.useState(null),[C,L]=h.useState(!1),[Y,I]=h.useState(!1),H=h.useRef(null),G=h.useRef(null),D=h.useRef(null);h.useEffect(()=>{I(!1)},[t==null?void 0:t.cacheKey]),h.useEffect(()=>{var u,j;if(v||b!=="regions"||$===null)return;const c=(u=G.current)==null?void 0:u.querySelector(`[data-region-item="${$}"]`);(j=c==null?void 0:c.scrollIntoView)==null||j.call(c,{block:"nearest"})},[$,b,v]),h.useEffect(()=>{if(!C)return;const c=j=>{var W,ne;const f=D.current;if(!f)return;const P=f.origX+(j.clientX-f.pointerStartX),K=f.origY+(j.clientY-f.pointerStartY),E=(W=p.current)==null?void 0:W.getBoundingClientRect(),k=(ne=H.current)==null?void 0:ne.getBoundingClientRect(),_=k&&k.width>0?k.width:f.elW,ie=k&&k.height>0?k.height:f.elH,xe=Pe(P,K,(E==null?void 0:E.width)??0,(E==null?void 0:E.height)??0,_,ie);w(xe)},u=()=>{D.current=null,L(!1)};return window.addEventListener("mousemove",c),window.addEventListener("mouseup",u),()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",u)}},[C,p]),h.useLayoutEffect(()=>{if(!g)return;const c=()=>{var P,K;const j=(P=p.current)==null?void 0:P.getBoundingClientRect(),f=(K=H.current)==null?void 0:K.getBoundingClientRect();!j||!f||j.width<=0||j.height<=0||w(E=>{if(!E)return null;const k=Pe(E.x,E.y,j.width,j.height,f.width,f.height);return k.x===E.x&&k.y===E.y?E:k})};c(),window.addEventListener("resize",c);let u=null;return typeof ResizeObserver<"u"&&(u=new ResizeObserver(c),p.current&&u.observe(p.current),H.current&&u.observe(H.current)),()=>{window.removeEventListener("resize",c),u==null||u.disconnect()}},[!!g,v,Y,p]);const R=c=>{var K,E;if(c.button!==0||De(c.target))return;const u=(K=p.current)==null?void 0:K.getBoundingClientRect(),j=(E=H.current)==null?void 0:E.getBoundingClientRect(),f=g!==null?g.x:u&&j&&u.width>0?j.left-u.left:he,P=g!==null?g.y:u&&j&&u.height>0?j.top-u.top:14;c.preventDefault(),D.current={pointerStartX:c.clientX,pointerStartY:c.clientY,origX:f,origY:P,elW:j&&j.width>0?j.width:344,elH:j&&j.height>0?j.height:420},L(!0)},q=c=>{De(c.target)||w(null)},F=(t==null?void 0:t.regions.length)??0,A=(t==null?void 0:t.changedFiles.length)??0,se=t?`${(t.totalDiffRatio*100).toFixed(1)}%`:"—",O=t!=null&&t.aiPowered?t.aiProvider||"AI":"本地解析",U=t?d.filter(c=>t.regions.some(u=>u.id===c)):[],ee=t&&$!==null?t.regions.find(c=>c.id===$)??null:null,ae=U.length>0||ee!==null,N=!!(t&&F>0&&y&&ae),B=U.length>0?`交给 Codex(已选 ${U.length} 处)`:ee?`交给 Codex(当前 #${String(ee.id).padStart(2,"0")})`:"交给 Codex",oe=((n==null?void 0:n.otherRouteEffects)??[]).filter(c=>typeof c.totalDiffRatio=="number"&&c.totalDiffRatio>=1e-4),J=n?n.legacy?"历史数据,无法判定":n.skipped?"已跳过":n.passed?"验收通过":"验收未通过":null,te=n?n.legacy?"var(--muted)":n.skipped?"#d97706":n.passed?"#16a34a":pe:void 0,V=g?{left:`${g.x}px`,top:`${g.y}px`,right:"auto"}:void 0;return v?e.jsxs("aside",{ref:H,"aria-label":n?"视觉验收检查器":"批注检查器","data-testid":"annotate-inspector-pill",className:"bl-inspector-pill",style:V,children:[e.jsxs("button",{type:"button","data-testid":"annotate-inspector-expand","aria-label":"展开批注检查器",title:"点击展开批注检查器",onClick:()=>o(!1),className:"bl-inspector-pill-main",children:[e.jsx("span",{className:"bl-inspector-pill-dot",style:{background:te??(F>0?"var(--accent)":"var(--faint)")},"aria-hidden":"true"}),n?e.jsxs("span",{className:"mono text-[11.5px] font-medium whitespace-nowrap",children:[J," · ",String(F).padStart(2,"0")," 项"]}):e.jsxs("span",{className:"mono text-[11.5px] font-medium whitespace-nowrap",children:["批注 ",String(F).padStart(2,"0")," · 变化 ",se]}),e.jsx(et,{size:12,className:"shrink-0 opacity-65","aria-hidden":"true"})]}),N&&y&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-4 w-px shrink-0",style:{background:"var(--hair-strong)"},"aria-hidden":"true"}),e.jsxs("button",{type:"button","data-testid":"annotate-inspector-pill-dispatch","aria-label":B,title:B,onClick:c=>{c.stopPropagation(),y()},className:"bl-inspector-pill-dispatch",children:[e.jsx(ke,{size:11}),e.jsx("span",{children:"交给 Codex"})]})]})]}):e.jsxs("aside",{ref:H,"aria-label":n?"视觉验收检查器":"批注检查器","data-testid":"annotate-inspector-panel","data-dragging":C?"true":void 0,className:"bl-inspector-float",style:V,children:[e.jsxs("div",{"data-testid":"annotate-inspector-drag-handle",title:"按住拖动移动位置 · 双击复位",onMouseDown:R,onDoubleClick:q,className:"bl-inspector-header shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(tt,{size:14,className:"bl-inspector-grip shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"text-[12.5px] font-semibold truncate",children:n?"视觉验收":"批注检查器"})]}),e.jsxs("button",{type:"button","data-testid":"annotate-inspector-collapse","aria-label":"收起批注检查器",title:"收起为迷你悬浮胶囊",onClick:()=>o(!0),className:"bl-inspector-collapse-btn shrink-0 inline-flex items-center gap-1",children:[e.jsx("span",{children:"收起"}),e.jsx(nt,{size:11.5})]})]}),e.jsxs("div",{"data-testid":"annotate-inspector-metrics",className:"bl-inspector-metrics shrink-0 mono text-[11px]",children:[e.jsxs("span",{className:"inline-flex items-baseline gap-1 shrink-0",children:[e.jsx("span",{style:{color:"var(--faint)"},children:"变动"}),e.jsx("strong",{style:{color:F>0?"var(--accent)":"var(--ink)"},children:String(F).padStart(2,"0")})]}),e.jsx("span",{className:"opacity-35","aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"inline-flex items-baseline gap-1 shrink-0",children:[e.jsx("span",{style:{color:"var(--faint)"},children:"占比"}),e.jsx("strong",{children:se})]}),e.jsx("span",{className:"opacity-35","aria-hidden":"true",children:"·"}),e.jsxs("span",{className:"shrink-0",children:[e.jsx("strong",{children:A})," 文件"]}),e.jsx("span",{className:"opacity-35","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"truncate",style:{color:"var(--muted)"},title:O,children:O})]}),n&&e.jsx("div",{className:"px-3 py-2 shrink-0",style:{borderBottom:"1px solid var(--hair)"},children:e.jsxs("div",{"data-verify-sidebar-summary":"true",className:"p-2.5 rounded-xl space-y-1.5 text-xs",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"caps",children:"自动视觉验收"}),e.jsx("span",{className:"mono text-[11px] font-semibold",style:{color:te},children:J})]}),!n.legacy&&!n.skipped&&e.jsxs("div",{className:"grid grid-cols-2 gap-1.5 text-[11px] mono",children:[e.jsxs("div",{className:"px-2 py-1.5 rounded-lg",style:{background:"var(--bg)",border:"1px solid var(--hair)"},children:[e.jsx("div",{className:"text-[10px]",style:{color:"var(--faint)"},children:"目标区内变化 (inside)"}),e.jsx("div",{className:"font-semibold mt-0.5",style:{color:"#16a34a"},children:n.insideChanged!==void 0?`${n.insideChanged} px`:"—"}),typeof n.hitRate=="number"&&e.jsxs("div",{className:"text-[10px]",style:{color:"var(--muted)"},children:["命中率 ",(n.hitRate*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"px-2 py-1.5 rounded-lg",style:{background:"var(--bg)",border:"1px solid var(--hair)"},children:[e.jsx("div",{className:"text-[10px]",style:{color:"var(--faint)"},children:"目标区外变化 (outside)"}),e.jsx("div",{className:"font-semibold mt-0.5",style:{color:(n.outsideChanged??0)>0&&!n.passed?pe:"var(--ink)"},children:n.outsideChanged!==void 0?`${n.outsideChanged} px`:"—"}),typeof n.outsideRatio=="number"&&e.jsxs("div",{className:"text-[10px]",style:{color:"var(--muted)"},children:["占比 ",(n.outsideRatio*100).toFixed(2),"%"]})]})]}),n.note&&e.jsx("p",{className:"text-[11px] leading-snug break-words",style:{color:"var(--muted)"},children:n.note}),oe.length>0&&e.jsxs("div",{className:"pt-1.5 space-y-1",style:{borderTop:"1px dashed var(--hair)"},"data-other-route-effects":"true",children:[e.jsxs("div",{className:"caps text-[10px]",style:{color:pe},children:["受影响的其他路由(",oe.length,")"]}),e.jsx("ul",{className:"space-y-1",children:oe.map(c=>e.jsxs("li",{className:"flex items-center justify-between gap-2 px-2 py-0.5 rounded text-[11px] mono",style:{background:`color-mix(in srgb, ${pe} 10%, transparent)`,border:`1px dashed color-mix(in srgb, ${pe} 45%, transparent)`},children:[e.jsxs("span",{className:"truncate",title:c.label||c.route,children:[c.route,c.label?` · ${c.label}`:""]}),e.jsxs("span",{className:"shrink-0 font-semibold",style:{color:pe},children:[(c.totalDiffRatio*100).toFixed(2),"%"]})]},c.route))})]})]})}),(t==null?void 0:t.summary)&&e.jsxs("div",{className:"px-3.5 py-2 shrink-0",style:{borderBottom:"1px solid var(--hair)"},children:[e.jsx("p",{"data-testid":"annotate-summary-text","data-expanded":Y?"true":"false",className:`bl-inspector-summary text-[12px] leading-relaxed ${Y?"is-expanded":""}`,style:{color:"var(--muted)"},children:t.summary}),e.jsx("button",{type:"button","data-testid":"annotate-summary-toggle","aria-expanded":Y,onClick:()=>I(c=>!c),className:"mt-1 text-[11px] font-medium hover:underline underline-offset-2",style:{color:"var(--accent)"},children:Y?"收起":"展开全部"})]}),e.jsxs("div",{className:"px-3.5 shrink-0 flex items-center gap-5",style:{borderBottom:"1px solid var(--hair)"},children:[e.jsxs("button",{type:"button",onClick:()=>z("regions"),className:"sheet-tab bl-subtab inline-flex items-center text-[12.5px]","aria-selected":b==="regions",children:[e.jsx("span",{children:"批注索引"}),e.jsx("span",{className:"bl-count-badge",children:F})]}),e.jsxs("button",{type:"button",onClick:()=>z("files"),className:"sheet-tab bl-subtab inline-flex items-center text-[12.5px]","aria-selected":b==="files",children:[e.jsx("span",{children:"源码改动"}),e.jsx("span",{className:"bl-count-badge",children:A})]})]}),e.jsx("div",{ref:G,className:"flex-1 min-h-0 overflow-y-auto px-3.5",children:t?b==="regions"?e.jsx(xt,{result:t,selectedId:$,checkedIds:U,onToggleCheck:S,onUpdateManualRegion:i,onDeleteManualRegion:a,onToggleSelect:X,onHoverRegion:s,onOpenFileDiff:m,onHoldingOriginalChange:r}):e.jsx(ht,{baseRef:t.baseRef,targetRef:t.targetRef,files:t.changedFiles,onOpenFileDiff:m}):e.jsx("div",{className:"py-10 text-xs",style:{color:"var(--faint)"},children:"运行批注后,此处按编号列出每处视觉变动。"})}),N&&y&&e.jsx("div",{className:"bl-inspector-footer shrink-0",children:e.jsxs("button",{type:"button",onClick:y,"data-testid":"annotate-dispatch-codex",className:"sheet-btn sheet-btn-primary w-full",style:{height:34,fontSize:12.5},children:[e.jsx(ke,{size:13}),e.jsx("span",{children:B})]})})]})},pt=[{id:"annotated",label:"红框新版"},{id:"original",label:"原版"},{id:"slider",label:"卷帘"},{id:"heatmap",label:"差异图"}],ut=({effectiveMode:t,showBoxes:n,holdingOriginal:p,drawMode:v=!1,drawDisabled:o=!1,onSubModeChange:b,onToggleBoxes:$,onToggleDrawMode:d,onHoldingOriginalChange:S})=>e.jsxs("div",{className:"flex items-center gap-2.5 xl:gap-3 text-[13px] font-medium flex-wrap",children:[e.jsx("div",{className:"flex items-center gap-3",children:pt.map(y=>e.jsx("button",{type:"button",onClick:()=>b(y.id),className:"pb-0.5 transition-colors",style:{color:t===y.id?y.id==="original"?"var(--accent)":"var(--ink)":"var(--muted)",fontWeight:t===y.id?600:480,borderBottom:t===y.id?`2px solid ${y.id==="original"?"var(--accent)":"var(--ink)"}`:"2px solid transparent"},children:y.label},y.id))}),d&&e.jsxs("button",{type:"button",onClick:d,disabled:o,"aria-pressed":v,"data-active":v?"true":void 0,"data-testid":"annotate-manual-draw-toggle",className:"bl-picker-toggle disabled:opacity-35",title:o?"卷帘模式下暂不可手动画框,请切回红框新版或原版":v?"正在手动拉框:在截图上拖拽绘制修改区域(再次点击退出)":"开启手动拉框,在截图任意位置拖拽框选并写下修改意见",children:[e.jsx(st,{size:13}),e.jsx("span",{children:v?"拉框中":"手动拉框"})]}),e.jsx("button",{type:"button",onClick:$,className:"hover:underline underline-offset-4",style:{color:"var(--muted)"},children:n?"隐藏红框":"显示红框"}),e.jsx("button",{type:"button",onMouseDown:()=>S(!0),onMouseUp:()=>S(!1),onMouseLeave:()=>S(!1),style:{color:p?"var(--accent)":"var(--ink)"},children:p?"■ 正在看原版":"按住看原版 (Space)"})]}),yt=({branches:t,baseRef:n,targetRef:p,route:v,onRouteChange:o,compareTargets:b,changeSummary:$,result:d,verificationOverlay:S,verificationHeader:y,loading:i,progressText:a,error:z,onBaseChange:X,onTargetChange:s,onRunAnnotate:m,onOpenFileDiff:r,onBackToLiveCompare:g,onBackToTree:w,onDispatchToCodex:C,onOpenPrDraft:L,onOpenBackendDiff:Y})=>{const[I,H]=h.useState("annotated"),[G,D]=h.useState(null),[R,q]=h.useState([]),[F,A]=h.useState(null),[se,O]=h.useState(!1),[U,ee]=h.useState(!0),[ae,N]=h.useState(!1),[B,oe]=h.useState(50),[J,te]=h.useState(!1),V=h.useRef(B);V.current=B;const[c,u]=h.useState("regions"),[j,f]=h.useState(ot),[P,K]=h.useState(!1),E=h.useRef(null),k=h.useRef(null),_=qe(l=>{var x;return((x=l.config)==null?void 0:x.chromePath)===null}),ie=Ve(l=>l.setSettingsOpen),xe=h.useCallback(l=>{f(l),lt(l)},[]),W=(d==null?void 0:d.cacheKey)??"",ne=ye(l=>l.manualRegionsByKey),ue=ye(l=>l.addManualRegion),be=ye(l=>l.updateManualRegion),ge=ye(l=>l.deleteManualRegion),me=h.useMemo(()=>W&&!S?ne[W]??[]:[],[W,S,ne]),T=h.useMemo(()=>d?me.length===0?d:{...d,regions:[...d.regions,...me]}:null,[d,me]);h.useEffect(()=>{(I==="slider"||I==="heatmap"||S)&&N(!1)},[I,S]),h.useEffect(()=>{d&&d.regions.length>0?(D(d.regions[0].id),q([])):(D(null),q([])),N(!1)},[d==null?void 0:d.cacheKey]);const fe=l=>{q(x=>x.includes(l)?x.filter(M=>M!==l):[...x,l])},Ie=h.useCallback(l=>{if(!T||!W||S)return;const M=T.regions.reduce((Z,we)=>Math.max(Z,we.id),0)+1,Q=String(M).padStart(2,"0");ue(W,{id:M,box:l.box,normBox:l.normBox,diffPixels:Math.max(1,l.box.width*l.box.height),diffRatio:0,category:"样式调整",title:`手动批注 #${Q}`,description:"",relatedFiles:[],domHints:["manual-box"],source:"manual"}),ee(!0),D(M),u("regions"),K(!1),q(Z=>Z.includes(M)?Z:[...Z,M])},[T,W,S,ue]),Ae=h.useCallback((l,x)=>{W&&be(W,l,x)},[W,be]),Ue=h.useCallback(l=>{W&&(ge(W,l),q(x=>x.filter(M=>M!==l)),D(x=>x===l?null:x),A(x=>x===l?null:x))},[W,ge]),Ke=()=>{if(!T||!C)return;const l=R.filter(M=>T.regions.some(Q=>Q.id===M)),x=l.length>0?T.regions.filter(M=>l.includes(M.id)):G!==null?T.regions.filter(M=>M.id===G):[];x.length!==0&&C(x,T)};h.useEffect(()=>{const l=M=>{if(M.code==="Space"&&!M.repeat){const Q=M.target,Z=Q==null?void 0:Q.tagName;if(Z==="INPUT"||Z==="TEXTAREA"||Z==="SELECT"||Q!=null&&Q.isContentEditable)return;M.preventDefault(),O(!0)}},x=M=>{M.code==="Space"&&O(!1)};return window.addEventListener("keydown",l),window.addEventListener("keyup",x),()=>{window.removeEventListener("keydown",l),window.removeEventListener("keyup",x)}},[]),h.useEffect(()=>{var $e;if(!J)return;let l=(($e=E.current)==null?void 0:$e.getBoundingClientRect())??null,x=null,M=null;const Q=re=>{var Re,Ee;const ce=l&&l.width>0?l:((Re=E.current)==null?void 0:Re.getBoundingClientRect())??null;if(!ce||ce.width<=0)return;l=ce;const Se=Math.max(1,Math.min(99,(re-ce.left)/ce.width*100));V.current=Se,(Ee=E.current)==null||Ee.style.setProperty("--bl-slider-pos",`${Se}%`)},Z=re=>{M=re.clientX,x===null&&(x=window.requestAnimationFrame(()=>{if(x=null,M!==null){const ce=M;M=null,Q(ce)}}))},we=()=>{var re;l=((re=E.current)==null?void 0:re.getBoundingClientRect())??null},je=()=>{if(x!==null&&(window.cancelAnimationFrame(x),x=null),M!==null){const re=M;M=null,Q(re)}oe(V.current),te(!1)};return window.addEventListener("pointermove",Z),window.addEventListener("mousemove",Z),window.addEventListener("pointerup",je),window.addEventListener("mouseup",je),window.addEventListener("resize",we),()=>{x!==null&&window.cancelAnimationFrame(x),window.removeEventListener("pointermove",Z),window.removeEventListener("mousemove",Z),window.removeEventListener("pointerup",je),window.removeEventListener("mouseup",je),window.removeEventListener("resize",we)}},[J]);const Ce=se?"original":I,We=h.useMemo(()=>{const l=[];n&&!t.some(x=>x.ref===n)&&l.push({value:n,label:`历史提交 ${n.slice(0,7)}`});for(const x of t)l.push({value:x.ref,label:x.label});return l},[t,n]),He=h.useMemo(()=>{const l=[];p&&!t.some(x=>x.ref===p)&&l.push({value:p,label:`历史提交 ${p.slice(0,7)}`});for(const x of t)l.push({value:x.ref,label:x.label});return l},[t,p]),Me=d?Math.max(($==null?void 0:$.backendFiles)??0,d.changedFiles.filter(l=>l.category==="backend").length):0,_e=!i&&!!d&&(d.regions.length===0||d.totalDiffRatio<.001)&&Me>0;return e.jsxs("div",{className:"bl-stage-enter flex-1 flex flex-col min-w-0 h-full relative z-10",children:[e.jsxs("div",{className:"bl-subbar bl-annotate-subbar min-h-11 py-1.5 px-4 xl:px-5 shrink-0 flex items-center justify-between gap-x-3 gap-y-2 flex-wrap z-10",children:[y?e.jsx("div",{className:"flex items-center gap-2.5 text-[13px] min-w-0 flex-1",children:y}):e.jsxs("div",{className:"flex items-center gap-2 text-[13px] flex-wrap",children:[e.jsx("button",{type:"button",onClick:w,className:"hover:underline underline-offset-4 font-medium shrink-0",style:{color:"var(--ink)"},children:"← 分支树"}),e.jsx("span",{style:{color:"var(--hair-strong)"},children:"|"}),e.jsx(Le,{value:n||"",options:We,onChange:X,ariaLabel:"原版分支",placeholder:"原版",size:"sm",minMenuWidth:184,className:"text-[12.5px] font-medium max-w-[132px]"}),e.jsx("span",{className:"mono",style:{color:"var(--faint)"},children:"→"}),e.jsx(Le,{value:p||"",options:He,onChange:s,ariaLabel:"目标分支",placeholder:"目标版",size:"sm",minMenuWidth:184,className:"text-[12.5px] font-medium max-w-[132px]"}),e.jsx("button",{type:"button",onClick:()=>m(!1),disabled:i||!n||!p||_,className:"sheet-link ml-1 disabled:opacity-35",style:{color:"var(--accent)",borderColor:"var(--accent)"},title:_?"未检测到本机 Chrome,请先在本机环境设置中安装配置":void 0,children:i?"分析中…":d?"运行批注":"开始批注 →"}),d&&e.jsx("button",{type:"button",onClick:()=>m(!0),disabled:i||_,title:"忽略缓存重新截图分析",className:"mono opacity-65 hover:opacity-100 disabled:opacity-35",children:"↻"}),j&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--hair-strong)"},"aria-hidden":"true",children:"|"}),e.jsx(ct,{route:v,changedPagesCount:b.length,onExpand:()=>xe(!1)})]})]}),(d||L)&&e.jsxs("div",{className:"flex items-center gap-2.5 flex-wrap",children:[d&&e.jsx(ut,{effectiveMode:Ce,showBoxes:U,holdingOriginal:se,drawMode:ae,drawDisabled:I==="slider",onSubModeChange:H,onToggleBoxes:()=>ee(l=>!l),onToggleDrawMode:S?void 0:()=>N(l=>{const x=!l;return x&&(ee(!0),I==="heatmap"&&H("annotated")),x}),onHoldingOriginalChange:O}),L&&e.jsxs("button",{type:"button",disabled:!d&&(!n||!p),onClick:()=>{const l=(d==null?void 0:d.baseRef)||n,x=(d==null?void 0:d.targetRef)||p;!l||!x||L({baseRef:l,targetRef:x,...d!=null&&d.cacheKey?{annotationCacheKey:d.cacheKey}:{}})},className:"sheet-btn text-xs py-1 px-2.5 disabled:opacity-35",title:"基于当前对比分支与视觉批注生成 PR 描述草稿",children:[e.jsx(at,{size:12}),e.jsx("span",{children:"生成 PR 描述"})]})]})]}),_&&e.jsx(Te,{context:"annotate",variant:"bar"}),_e&&e.jsxs("div",{role:"status","data-testid":"annotate-no-visual-diff-banner",className:"bl-handoff-banner px-6 py-2 shrink-0 flex items-center justify-between gap-3 flex-wrap text-xs z-10",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(ke,{size:13,style:{color:"var(--accent)"},className:"shrink-0"}),e.jsxs("span",{className:"font-medium",style:{color:"var(--ink)"},children:["当前前端界面未发现明显视觉差异,检测到 ",Me," 处后端变动"]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>Y==null?void 0:Y("plain"),className:"sheet-btn sheet-btn-primary text-xs py-1 px-2.5",children:"查看 AI 通俗总结"}),e.jsx("button",{type:"button",onClick:()=>Y==null?void 0:Y("code"),className:"sheet-btn text-xs py-1 px-2.5",children:"查看代码差异"})]})]}),!y&&!j&&e.jsx(rt,{route:v,compareTargets:b,onRouteChange:o,onCollapse:()=>xe(!0)}),e.jsxs("div",{ref:k,"data-testid":"annotator-viewport",className:"flex-1 min-h-0 relative flex overflow-hidden z-10",children:[e.jsx(dt,{branches:t,baseRef:n,targetRef:p,route:v,result:T,verificationOverlay:S,chromeMissing:_,drawMode:ae&&!S,loading:i,progressText:a,error:z,effectiveMode:Ce,showBoxes:U,sliderPos:B,selectedId:G,hoveredId:F,stageRef:E,onDragSliderStart:()=>te(!0),onCreateManualRegion:Ie,onSelectRegion:l=>{D(l),u("regions"),K(!1)},onHoverRegion:A,onTargetChange:s,onRunAnnotate:m,onOpenEnvSettings:()=>ie(!0,"env"),onBackToLiveCompare:g,onBackToTree:w}),!i&&!z&&!!(T||S)&&e.jsx(mt,{result:T,verificationOverlay:S,viewportRef:k,collapsed:P,onCollapsedChange:K,rightTab:c,selectedId:G,checkedIds:R,onToggleCheck:C?fe:void 0,onDispatchToCodex:C?Ke:void 0,onUpdateManualRegion:S?void 0:Ae,onDeleteManualRegion:S?void 0:Ue,onRightTabChange:u,onToggleSelect:l=>D(G===l?null:l),onHoverRegion:A,onOpenFileDiff:r,onHoldingOriginalChange:O})]})]})};export{yt as AiAnnotator};
@@ -0,0 +1,30 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ExecutionTraceView-BuKMTJLz.js","./vendor-react-CIotE-6Q.js","./index-CuRBE0Be.js","./vendor-icons-BeN0on9X.js","./index-B76NgI6o.css","./LiquidSelect-BcHivJrw.js","./ExecutionTraceView-BI9foB9i.css"])))=>i.map(i=>d[i]);
2
+ var ss=Object.defineProperty;var rs=(e,s,n)=>s in e?ss(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n;var ut=(e,s,n)=>rs(e,typeof s!="symbol"?s+"":s,n);import{a as Xt,S as dn,s as as,b as zt,d as is,u as os,y as st,z as cs,j as ls,E as ds,F as us,G as vt,k as un,I as hn,A as hs,f as ms,_ as fs}from"./index-CuRBE0Be.js";import{c as ps,r as o,j as t,R as ct}from"./vendor-react-CIotE-6Q.js";import{L as Nt}from"./LiquidSelect-BcHivJrw.js";import"./vendor-icons-BeN0on9X.js";function gt(e,s){const n=new Map;for(const d of e)n.set(d.id,d);const r=new Map,a=new Map,u=new Map,i=new Map;for(const d of s){if(!n.has(d.fromId)||!n.has(d.toId))continue;let m=r.get(d.fromId);m||(m=[],r.set(d.fromId,m)),m.push(d);let l=a.get(d.toId);if(l||(l=[],a.set(d.toId,l)),l.push(d),d.kind==="fork"){let x=u.get(d.fromId);x||(x=[],u.set(d.fromId,x)),x.includes(d.toId)||x.push(d.toId);let y=i.get(d.toId);y||(y=[],i.set(d.toId,y)),y.includes(d.fromId)||y.push(d.fromId)}}return{nodeById:n,outgoingById:r,incomingById:a,forkChildrenById:u,forkParentsById:i}}function mn(e,s){const n=new Set,r=new Set;if(!e)return{nodeIds:n,edgeIds:r};const a=s.nodeById.get(e);if(!a)return{nodeIds:n,edgeIds:r};if(n.add(e),a.status==="trunk"){const l=[e];for(;l.length>0;){const x=l.shift();for(const y of s.outgoingById.get(x)??[])y.kind==="fork"&&(r.add(y.id),n.has(y.toId)||(n.add(y.toId),l.push(y.toId)))}return{nodeIds:n,edgeIds:r}}const u=[e],i=new Set([e]);for(;u.length>0;){const l=u.shift();for(const x of s.incomingById.get(l)??[]){if(x.kind==="trunk")continue;r.add(x.id),n.add(x.fromId);const y=s.nodeById.get(x.fromId);y&&y.status!=="trunk"&&!i.has(x.fromId)&&(i.add(x.fromId),u.push(x.fromId))}}const d=[e],m=new Set([e]);for(;d.length>0;){const l=d.shift();for(const x of s.outgoingById.get(l)??[]){if(x.kind==="trunk")continue;r.add(x.id),n.add(x.toId);const y=s.nodeById.get(x.toId);y&&y.status!=="trunk"&&!m.has(x.toId)&&(m.add(x.toId),d.push(x.toId))}}return{nodeIds:n,edgeIds:r}}function Tn(e,s,n){if(n==null)return null;const r=gt(e,s),a=new Set;if(!r.nodeById.has(n))return a;const u=[n];for(;u.length>0;){const i=u.pop();if(!a.has(i)){a.add(i);for(const d of r.forkChildrenById.get(i)??[])a.has(d)||u.push(d)}}return a}function gs(e,s,n){var x;const r=gt(e,s),a=r.forkChildrenById,u=new Set,i=new Set;for(const y of n){if(!r.nodeById.has(y))continue;const M=new Set([y]),$=[y];for(;$.length>0;){const k=$.pop();for(const w of a.get(k)??[])w===y&&i.add(y),!M.has(w)&&(M.add(w),u.add(w),$.push(w))}}for(const y of i)u.delete(y);const d=new Map,m=new Set;for(const y of e){if(d.has(y.id))continue;const M=[{id:y.id,children:a.get(y.id)??[],index:0}],$=[y.id];let k=null,w=null,T=0;for(m.add(y.id);M.length>0;){const j=M[M.length-1];if(j.index<j.children.length){const D=j.children[j.index++];if(d.has(D))continue;if(m.has(D)){k=D,w=new Set($.slice($.indexOf(D))),T=0;continue}m.add(D),$.push(D),M.push({id:D,children:a.get(D)??[],index:0})}else{M.pop(),$.pop(),m.delete(j.id);let D=0;for(const A of j.children)w!==null&&w.has(A)||(D+=1+(d.get(A)??0));if(w!==null&&w.has(j.id)&&(T+=D),w!==null&&j.id===k){const A=w.size-1;for(const G of w)d.set(G,A+T);k=null,w=null}else d.set(j.id,D)}}}const l=new Map;for(const y of e)l.set(y.id,((x=a.get(y.id))==null?void 0:x.length)??0);return{visibleNodes:e.filter(y=>!u.has(y.id)),hiddenIds:u,childCounts:l,descendantCounts:d}}function xs(e,s,n,r){const a=gt(e,s),u=new Set(r),i=new Set([n]),d=[...a.forkParentsById.get(n)??[]];for(;d.length>0;){const m=d.pop();if(!i.has(m)){i.add(m),u.delete(m);for(const l of a.forkParentsById.get(m)??[])i.has(l)||d.push(l)}}return u}const bs=/[((]\s*(?:v\d[\w.-]*|release[-/][\w.-]+|tag[::]\s*\S+)(?:[、,,]\s*[\w./-]+)*\s*[))]\s*$/i;function ys(e){var n,r,a;if(e.status!=="trunk")return!1;const s=(a=(r=(n=e.evidence)==null?void 0:n.commitMessages)==null?void 0:r[0])==null?void 0:a.trim();if(s&&e.title.startsWith(s)){const u=e.title.slice(s.length).trim();if(/^(.+)$/.test(u))return!0}return bs.test(e.title)}function Ln(e,s,n){const r=e.filter(g=>g.status==="trunk");if(!n.enabled||r.length<=2)return{nodes:[...e],edges:s.map(g=>({...g})),segments:[],hiddenTrunkIds:new Set,keptTrunkIds:new Set(r.map(g=>g.id))};const a=n.expandedSegmentIds??new Set,u=new Set(r.map(g=>g.id)),i=new Map(r.map(g=>[g.id,g])),d=new Map,m=new Map,l=new Set;for(const g of s)g.kind==="trunk"&&u.has(g.fromId)&&u.has(g.toId)?!d.has(g.fromId)&&!m.has(g.toId)&&(d.set(g.fromId,g.toId),m.set(g.toId,g.fromId)):(g.kind==="fork"||g.kind==="merge")&&(u.has(g.fromId)&&l.add(g.fromId),u.has(g.toId)&&l.add(g.toId));const x=[],y=new Set,M=r.filter(g=>!m.has(g.id));for(const g of M){let V=g.id;for(;V&&!y.has(V);){y.add(V);const ae=i.get(V);ae&&x.push(ae),V=d.get(V)}}for(const g of r)y.has(g.id)||x.push(g);const $=g=>l.has(g.id)||ys(g),k=x.some($),w=new Set;for(let g=0;g<x.length;g+=1){const V=x[g];($(V)||!k&&(g===0||g===x.length-1))&&w.add(V.id)}const T=[],j=new Set,D=[];let A=0,G=null;for(;A<x.length;){const g=x[A];if(w.has(g.id)){G=g.id,A+=1;continue}const V=A,ae=g.phaseId;for(;A<x.length&&!w.has(x[A].id);)A+=1;const L=x.slice(V,A),ie=A<x.length&&w.has(x[A].id)?x[A].id:null,te=`trunk-seg:${L[0].id}..${L[L.length-1].id}`;if(a.has(te)){for(const ce of L)w.add(ce.id);G=L[L.length-1].id;continue}T.push({id:te,phaseId:ae,fromNodeId:G,toNodeId:ie,nodes:L,count:L.length});for(const ce of L)j.add(ce.id);G&&ie&&D.push({id:`trunk-collapsed:${G}->${ie}`,fromId:G,toId:ie,kind:"trunk",collapsedSegmentId:te,collapsedCount:L.length})}const R=e.filter(g=>!j.has(g.id)),f=s.filter(g=>!j.has(g.fromId)&&!j.has(g.toId)).map(g=>({...g})),B=new Set(f.map(g=>`${g.fromId}->${g.toId}`));for(const g of D){const V=`${g.fromId}->${g.toId}`;B.has(V)||(f.push(g),B.add(V))}return{nodes:R,edges:f,segments:T,hiddenTrunkIds:j,keptTrunkIds:w}}function ws(e,s){const n=[],r=new Set,a=new Map;for(const i of e){let d=a.get(i.fromId);d||(d=[],a.set(i.fromId,d)),d.push(i),s.has(i.fromId)&&s.has(i.toId)&&(r.add(`${i.fromId}->${i.toId}`),n.push({...i,spanning:!1}))}const u=new Set(r);for(const i of s){const d=a.get(i);if(!d)continue;const m=[],l=new Set;for(const x of d)s.has(x.toId)||l.has(x.toId)||(l.add(x.toId),m.push({id:x.toId,depth:1,kind:x.kind}));for(;m.length>0;){const x=m.shift();for(const y of a.get(x.id)??[])if(y.toId!==i)if(s.has(y.toId)){const M=`${i}->${y.toId}`;if(!u.has(M)){u.add(M);const $=x.kind==="trunk"&&y.kind==="trunk"?"trunk":y.kind==="merge"?"merge":"fork";n.push({id:`span:${i}->${y.toId}`,fromId:i,toId:y.toId,kind:$,spanning:!0,skippedCount:x.depth})}}else l.has(y.toId)||(l.add(y.toId),m.push({id:y.toId,depth:x.depth+1,kind:x.kind}))}}return n}function ks(e,s,n,r){const a=e.x+n,u=e.y+r/2,i=s.x,d=s.y+r/2,m=Math.min(110,Math.max(36,Math.abs(i-a)*.2));return`M ${a} ${u} C ${a+m} ${u}, ${i-m} ${d}, ${i} ${d}`}function An(e,s,n,r){if(s.x>e.x+n-8)return ks(e,s,n,r);const a=e.y>s.y,u=e.x+n/2,i=a?e.y:e.y+r,d=s.x+n/2,m=a?s.y+r:s.y,l=(i+m)/2;return`M ${u} ${i} C ${u} ${l}, ${d} ${l}, ${d} ${m}`}const vs=65536;class Gt{constructor(s=1024,n=268,r=152){ut(this,"cellSize");ut(this,"width");ut(this,"height");ut(this,"cells",new Map);ut(this,"keysById",new Map);ut(this,"items",new Map);this.cellSize=s,this.width=n,this.height=r}get size(){return this.items.size}get(s){return this.items.get(s)}cellKeys(s){const n=[],r=Math.floor(s.left/this.cellSize),a=Math.floor(s.right/this.cellSize),u=Math.floor(s.top/this.cellSize),i=Math.floor(s.bottom/this.cellSize);if(![r,a,u,i].every(Number.isSafeInteger)||a<r||i<u||(a-r+1)*(i-u+1)>vs)return n;for(let d=r;d<=a;d+=1)for(let m=u;m<=i;m+=1)n.push(`${d},${m}`);return n}set(s){this.delete(s.id);const{x:n,y:r}=s.position;if(!Number.isFinite(n)||!Number.isFinite(r))return;const a=this.cellKeys({left:n,right:n+this.width,top:r,bottom:r+this.height});for(const u of a){let i=this.cells.get(u);i||(i=new Set,this.cells.set(u,i)),i.add(s.id)}this.keysById.set(s.id,a),this.items.set(s.id,s)}delete(s){const n=this.keysById.get(s);if(n)for(const r of n){const a=this.cells.get(r);a&&(a.delete(s),a.size===0&&this.cells.delete(r))}this.keysById.delete(s),this.items.delete(s)}clear(){this.cells.clear(),this.keysById.clear(),this.items.clear()}query(s){const n=new Set,r=[];for(const a of this.cellKeys(s)){const u=this.cells.get(a);if(u)for(const i of u){if(n.has(i))continue;n.add(i);const d=this.items.get(i);if(!d)continue;const{x:m,y:l}=d.position;m+this.width<s.left||m>s.right||l+this.height<s.top||l>s.bottom||r.push(d)}}return r}}function Ns(e,s,n,r){return e.x<s.x+n&&e.x+n>s.x&&e.y<s.y+r&&e.y+r>s.y}function js(e,s,n){if(e instanceof Map){const a=e.get(s);return a||(n?e.get(n):void 0)}const r=e;if(Object.prototype.hasOwnProperty.call(r,s))return r[s];if(n&&Object.prototype.hasOwnProperty.call(r,n))return r[n]}function Cs(e,s,n){const r=n.minY??0,a=new Gt(1024,n.width,n.height),u=new Array(e.length);for(let i=0;i<e.length;i+=1){const d=e[i],m=js(s,d.id,d.positionKey);if(m&&Number.isFinite(m.x)&&Number.isFinite(m.y)){const l={x:m.x,y:Math.max(r,m.y)};a.set({id:d.id,position:l}),u[i]={...d,position:l,positionLocked:!0}}}for(let i=0;i<e.length;i+=1){if(u[i])continue;const d=e[i],m={x:Math.round(d.naturalPosition.x),y:Math.max(r,Math.round(d.naturalPosition.y))};for(let x=0;x<e.length+2;x+=1){const y=a.query({left:m.x,right:m.x+n.width,top:m.y,bottom:m.y+n.height}).filter(M=>Ns(m,M.position,n.width,n.height));if(y.length===0)break;m.y=Math.max(...y.map(M=>M.position.y+n.height+n.gapY))}const l={...d,position:m,positionLocked:!1};a.set({id:d.id,position:m}),u[i]=l}return u}const Mt={phaseId:"all",originGroup:"all",statusGroup:"all",impact:"all"},Bt={"agent-chronicle":{shortLabel:"✦ 开发 Agent 历程",group:"agent",tone:"agent"},"agent-report":{shortLabel:"✦ 开发 Agent 说明",group:"agent",tone:"agent"},"branch-lens-task":{shortLabel:"BranchLens 任务",group:"task",tone:"task"},"ai-synthesis":{shortLabel:"AI 综合整理",group:"ai-git",tone:"ai"},"git-static":{shortLabel:"Git 拓扑",group:"ai-git",tone:"git"}},Ut={merged:{label:"已合入",tone:"merged"},accepted:{label:"已采纳",tone:"merged"},active:{label:"进行中",tone:"active"},trunk:{label:"主干",tone:"trunk"},working:{label:"未提交",tone:"working"},archived:{label:"已归档",tone:"archived"}},Jt={frontend:{label:"前端",tone:"frontend"},backend:{label:"后端",tone:"backend"},fullstack:{label:"全栈",tone:"fullstack"},config:{label:"配置",tone:"config"},docs:{label:"文档",tone:"docs"},unknown:{label:"其他",tone:"unknown"}},Pt={dsh:{shortLabel:"✦ DSH 对话",tone:"agent"},codex:{shortLabel:"✦ Codex 对话",tone:"agent"},"branch-lens":{shortLabel:"BranchLens 任务",tone:"task"},"agent-report":{shortLabel:"✦ 外部 Agent 说明",tone:"agent"},"git-inferred":{shortLabel:"Git 归纳",tone:"git"}},Ss="原始需求尚未记录",Is=/^(?:按对话需求梳理|按分支梳理|按完整提交梳理|完整提交视图|完整提交粒度视图|共梳理|系统梳理)/;function Es(e){var n;const s=((n=e.overview)==null?void 0:n.trim())??"";return!!(!s||Is.test(s)||e.primaryOrigin!=="agent-chronicle")}function yt(e){var n;if(typeof e.hasRecordedRequirement=="boolean")return e.hasRecordedRequirement;const s=((n=e.requirementOrigin)==null?void 0:n.trim())??"";return!!(s&&s!==Ss)}function en(e){var s;return e.conversationSource&&Pt[e.conversationSource]?Pt[e.conversationSource].tone:((s=Bt[e.kind])==null?void 0:s.tone)??"git"}function tn(e){var a;if(e.conversationSource&&Pt[e.conversationSource])return Pt[e.conversationSource].shortLabel;const s=e.label||((a=Bt[e.kind])==null?void 0:a.shortLabel)||e.kind,n=e.kind==="agent-chronicle"||e.kind==="agent-report"?"✦ ":"",r=e.agentName?` · ${e.agentName}`:"";return`${n}${s}${r}`}function fn(e){if(!e)return"";let r=e.replace(/\r\n?/g,`
3
+ `).split(`
4
+ `).map(a=>{let u=a.trim();if(!u||/^```[\w-]*$/.test(u))return"";let i="";for(;u!==i;)i=u,u=u.replace(/^>+\s*/,"").replace(/^#{1,6}\s+/,"").replace(/^[-*+]\s+/,"");return u}).filter(Boolean).join(" ");return r=r.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1"),r=r.replace(/\[([^\]]+)\]\([^)]*\)/g,"$1"),r=r.replace(/`+([^`]+)`+/g,"$1"),r=r.replace(/\*\*((?:(?!\*\*).)+)\*\*/g,"$1"),r=r.replace(/__((?:(?!__).)+)__/g,"$1"),r=r.replace(/~~((?:(?!~~).)+)~~/g,"$1"),r=r.replace(/(^|[\s([{"'「(])\*([^*\s][^*]*?)\*(?=[\s)\]}",.!?;:,。!?;:」)、]|$)/g,"$1$2"),r=r.replace(/(^|[\s([{"'「(])_([^_\s][^_]*?)_(?=[\s)\]}",.!?;:,。!?;:」)、]|$)/g,"$1$2"),r.replace(/\s+/g," ").trim()}function Tt(e){if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return e;const n=new Date(s),r=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0"),u=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0");return`${n.getFullYear()}-${r}-${a} ${u}:${i}`}function Rt(e){if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const n=new Date(s);return`${String(n.getMonth()+1).padStart(2,"0")}/${String(n.getDate()).padStart(2,"0")}`}function _n(e){return e.phaseId!=="all"||e.originGroup!=="all"||e.statusGroup!=="all"||e.impact!=="all"}function $n(e,s){return e.filter(n=>{var r;if(s.phaseId!=="all"&&n.phaseId!==s.phaseId||s.originGroup!=="all"&&(((r=Bt[n.origin.kind])==null?void 0:r.group)??"ai-git")!==s.originGroup)return!1;if(s.statusGroup!=="all"){if(s.statusGroup==="merged"){if(n.status!=="merged"&&n.status!=="accepted")return!1}else if(n.status!==s.statusGroup)return!1}return!(s.impact!=="all"&&n.impactCategory!==s.impact)})}const Xe=268,Ae=152,Ms=52,pt=28,it=114,Rs=20,Ps=13,Vt=70,Ts=108,jt=20,Ls=18,Ft=28,ht=156,Ct=156;function As(e,s,n,r,a={}){var H,F;const u=new Gt(1024,Xe,Ae),i=gt([],[]);if(s.length===0)return{width:640,height:260,phaseHeaderHeight:Vt,laneCount:1,laneLabels:[`主干 · ${r}`],hasTrunkLane:!0,phaseBands:[],nodes:[],allStructuralNodes:[],nodeById:new Map,edges:[],regionIndex:u,adjacency:i,childCounts:new Map,descendantCounts:new Map,collapsedSegments:[],hiddenTrunkCount:0,keptTrunkColumns:0};const d=a.trunkFold??Ln(s,n,{enabled:!!a.trunkCollapseEnabled,expandedSegmentIds:a.expandedTrunkSegmentIds}),m=d.nodes,l=d.edges,x=new Map;for(const p of l){const I=x.get(p.toId)??[];I.push(p),x.set(p.toId,I)}const y=[...e].sort((p,I)=>p.order-I.order),M=new Set(y.map(p=>p.id)),$=m.filter(p=>!M.has(p.phaseId)),k=[];for(const p of y){const I=m.filter(h=>h.phaseId===p.id).sort((h,S)=>Date.parse(h.timestamp)-Date.parse(S.timestamp));I.length>0&&k.push({phase:p,nodes:I})}$.length>0&&k.push({phase:{id:"__other__",order:y.length+1,title:"其他演进记录",goal:"尚未归类的提交与分支节点",summary:"",nodeIds:$.map(p=>p.id)},nodes:$.sort((p,I)=>Date.parse(p.timestamp)-Date.parse(I.timestamp))});const w=new Map,T=new Map,j=new Map,D=new Map,A=(p,I)=>{let h=j.get(p);h||(h=new Set,j.set(p,h)),h.add(I)};let G=0,R=-1,f=0;const B=[];for(const p of k){const I=G;let h=I;for(const S of p.nodes){let O=I;for(const xe of x.get(S.id)??[]){const $e=w.get(xe.fromId);$e!==void 0&&(O=Math.max(O,$e+1))}let Q=0;if(S.status==="trunk")R>=O&&(O=R+1),Q=0,R=O;else{const xe=D.get(S.ref);if(xe!==void 0&&!((H=j.get(O))!=null&&H.has(xe)))Q=xe;else{for(Q=1;(F=j.get(O))!=null&&F.has(Q);)Q+=1;D.has(S.ref)||D.set(S.ref,Q)}}A(O,Q),w.set(S.id,O),T.set(S.id,Q),O>h&&(h=O),Q>f&&(f=Q)}B.push({phase:p.phase,nodes:p.nodes,startCol:I,endCol:h}),G=h+1}const g=new Set,V=new Map,ae=new Set;for(const p of d.segments){const I=p.fromNodeId?w.get(p.fromNodeId):void 0,h=p.toNodeId?w.get(p.toNodeId):void 0;if(I===void 0&&h!==void 0)g.add(h);else if(I!==void 0&&h!==void 0){const S=V.get(h);V.set(h,S===void 0?I:Math.max(S,I))}else I!==void 0&&h===void 0&&ae.add(I)}const L=new Map,ie=[];let te=it;for(const p of B){const I=V.get(p.startCol);if(I!==void 0&&I<p.startCol){const Q=L.get(I);if(Q!==void 0){const $e=te+jt-(Q+Xe);$e<Ct&&(te+=Ct-$e)}}const h=te;let S=h+jt;for(let Q=p.startCol;Q<=p.endCol;Q+=1){if(Q===p.startCol)g.has(Q)&&(S+=ht);else{let xe=Ms;g.has(Q)&&(xe=Math.max(xe,ht));const $e=V.get(Q);if($e!==void 0){const Fe=L.get($e);if(Fe!==void 0){const Qe=S+xe-(Fe+Xe);Qe<Ct&&(xe+=Ct-Qe)}}S+=xe}L.set(Q,S),S+=Xe}ae.has(p.endCol)&&(S+=ht);const O=S-h+jt;ie.push({phase:p.phase,x:h,width:O,startCol:p.startCol,endCol:p.endCol,nodeCount:p.nodes.length}),te=h+O+Ls}const ce=Tn(m,l,a.focusedNodeId??null),U=gs(m,l,a.collapsedBranchIds??new Set),Ce=a.filters&&_n(a.filters)?new Set($n(m,a.filters).map(p=>p.id)):null,K=new Set;let Y=!1,se=1/0,Te=0;for(const p of m){if(ce!==null&&!ce.has(p.id)||U.hiddenIds.has(p.id)||Ce!==null&&!Ce.has(p.id))continue;K.add(p.id);const I=T.get(p.id)??0;I===0&&(Y=!0),I<se&&(se=I),I>Te&&(Te=I)}const re=d.segments.some(p=>{const I=!!(p.fromNodeId&&K.has(p.fromNodeId)),h=!!(p.toNodeId&&K.has(p.toNodeId));return p.fromNodeId&&p.toNodeId?I&&h:!p.fromNodeId&&p.toNodeId?h:p.fromNodeId&&!p.toNodeId?I:!1}),Z=K.size>0&&!Y&&!re&&se>=1,ue=Z?se:0,we=!Z,Pe=a.showPhaseSummary!==!1&&ie.some(p=>{var I;return!!((I=p.phase.summary)!=null&&I.trim())})?Ts:Vt,Ne=B.flatMap(p=>p.nodes.map(I=>{const h=w.get(I.id)??0,S=T.get(I.id)??0,O=Z?Math.max(0,S-ue):S,Q=L.get(h)??it,xe=Pe+20+O*(Ae+pt);return{id:I.id,node:I,col:h,lane:O,rawLane:S,naturalPosition:{x:Q,y:xe}}})),be=Z?Ne.filter(p=>K.has(p.id)):Ne,De=Cs(be,a.lockedPositions??{},{width:Xe,height:Ae,gapY:pt,minY:Pe+20}),Se=new Map(De.map(p=>[p.id,p])),he=Z?Math.max(0,Te-ue):f,_e=[],Ie=new Map,me=[],We=new Gt(1024,Xe,Ae);let ne=te+12,ze=Pe+20+(he+1)*Ae+Math.max(0,he)*pt+Ft;for(const p of Ne){const I=Se.get(p.id),h=I?I.position:p.naturalPosition,S=I?I.positionLocked:!1,O={id:p.id,node:p.node,col:p.col,lane:p.lane,x:h.x,y:h.y,cx:h.x+Xe/2,cy:h.y+Ae/2,position:h,positionLocked:S};_e.push(O),Ie.set(p.id,O),K.has(p.id)?(me.push(O),We.set(O),ne=Math.max(ne,h.x+Xe+48),ze=Math.max(ze,h.y+Ae+Ft)):Z||(ne=Math.max(ne,h.x+Xe+48),ze=Math.max(ze,h.y+Ae+Ft))}const pe=ws(l,K),v=[];for(const p of pe){const I=Ie.get(p.fromId),h=Ie.get(p.toId);if(!I||!h)continue;const S=An(I.position,h.position,Xe,Ae);v.push({id:p.id,fromId:p.fromId,toId:p.toId,edge:p,from:I,to:h,path:S,spanning:p.spanning})}const W=[];for(const p of d.segments){const I=p.fromNodeId?Ie.get(p.fromNodeId):void 0,h=p.toNodeId?Ie.get(p.toNodeId):void 0;if(I&&h&&K.has(I.id)&&K.has(h.id))W.push({segment:p,kind:"middle",x:(I.x+Xe+h.x)/2,y:(I.cy+h.cy)/2});else if(!I&&h&&K.has(h.id)){const S=h.x-ht,O=S+ht/2;W.push({segment:p,kind:"leading",x:O,y:h.cy,lineStartX:Math.max(it+8,S+10),lineEndX:h.x})}else if(I&&!h&&K.has(I.id)){const S=I.x+Xe,O=S+ht/2,Q=S+ht;W.push({segment:p,kind:"trailing",x:O,y:I.cy,lineStartX:S,lineEndX:Q-10}),ne=Math.max(ne,Q+jt+12)}}const oe=he+1,ge=Array.from({length:oe},(p,I)=>{const h=I+ue;if(we&&h===0)return`主干 · ${r}`;const S=(Z?me:_e).filter(Q=>Q.lane===I);return S.some(Q=>Q.node.status==="working")&&S.length===1?"当前工作区":`迭代轨 ${String(h).padStart(2,"0")}`}),J=gt(me.map(p=>p.node),v.map(p=>p.edge));return{width:Math.max(760,ne),height:ze,phaseHeaderHeight:Pe,laneCount:oe,laneLabels:ge,hasTrunkLane:we,phaseBands:ie,nodes:me,allStructuralNodes:_e,nodeById:Ie,edges:v,regionIndex:We,adjacency:J,childCounts:U.childCounts,descendantCounts:U.descendantCounts,collapsedSegments:W,hiddenTrunkCount:d.hiddenTrunkIds.size,keptTrunkColumns:d.keptTrunkIds.size}}function _s(e,s,n){if(!e)return{nodeIds:new Set,edgeIds:new Set};if(n&&!Array.isArray(n))return mn(e,n);const r=Array.isArray(n)?n:Array.from(new Set(s.flatMap(u=>[u.fromId,u.toId]))).map(u=>({id:u,phaseId:"",ref:u,title:u,sha:"",shortSha:"",parentRef:"",mergeBaseSha:"",status:u.startsWith("trunk:")?"trunk":"active",timestamp:"",requirementOrigin:"",summary:"",improvements:[],impactCategory:"unknown",origin:{kind:"git-static",label:""},evidence:{commitShas:[],changedFilesCount:0}})),a=gt(r,s);return mn(e,a)}const $s="branch-lens:chronicle-positions:v1:",Bn="branch-lens:chronicle-quick-phrases:v1",On="branch-lens:chronicle-show-phase-summary:v1",Bs=new Map;function St(e,s){return`${e}::${s}`}const Lt=Object.freeze(["展开说明","举例","对比解释","补测试"]),Dn=12,zn=16;function Fn(e="swimlane"){return{viewMode:e,userPickedView:!1,filters:{...Mt},selectedNodeId:null,focusedNodeId:null,trunkCollapseEnabled:!0,expandedTrunkSegmentIds:[],collapsedBranchIds:[],camera:null,cameraInitialized:!1,arrangeSeq:0}}function Yt(e){return`${$s}${e}`}function pn(e){if(!e)return{};try{const s=window.localStorage.getItem(Yt(e));if(!s)return{};const n=JSON.parse(s);if(!n||typeof n!="object"||Array.isArray(n))return{};const r={};for(const[a,u]of Object.entries(n))u&&typeof u=="object"&&!Array.isArray(u)&&typeof u.x=="number"&&typeof u.y=="number"&&Number.isFinite(u.x)&&Number.isFinite(u.y)&&(r[a]={x:Math.round(u.x),y:Math.round(u.y)});return r}catch{return{}}}function gn(e,s){if(e)try{Object.keys(s).length===0?window.localStorage.removeItem(Yt(e)):window.localStorage.setItem(Yt(e),JSON.stringify(s))}catch{}}function Os(e){if(!Array.isArray(e))return[...Lt];const s=[];for(const n of e){const r=typeof n=="string"?n.trim().slice(0,zn):"";if(r&&!s.includes(r)&&s.push(r),s.length>=Dn)break}return s}function xn(){try{const e=window.localStorage.getItem(Bn);return e===null?[...Lt]:Os(JSON.parse(e))}catch{return[...Lt]}}function Ht(e){try{window.localStorage.setItem(Bn,JSON.stringify(e))}catch{}}function bn(){try{const e=window.localStorage.getItem(On);return!(e==="false"||e==="0")}catch{return!0}}function yn(e){try{window.localStorage.setItem(On,e?"true":"false")}catch{}}function at(e,s,n){const r=e.byRepo[s]??Fn(),a=n(r);return{byRepo:{...e.byRepo,[s]:a}}}const ye=ps(e=>({byRepo:{},lockedPositionsByRepo:{},quickPhrases:xn(),showPhaseSummary:bn(),ensureRepo:(s,n)=>e(r=>{const a={};return r.byRepo[s]||(a.byRepo={...r.byRepo,[s]:Fn(n)}),r.lockedPositionsByRepo[s]||(a.lockedPositionsByRepo={...r.lockedPositionsByRepo,[s]:pn(s)}),a}),setViewMode:(s,n,r=!0)=>e(a=>at(a,s,u=>({...u,viewMode:n,userPickedView:r?!0:u.userPickedView}))),setFilters:(s,n)=>e(r=>at(r,s,a=>({...a,filters:typeof n=="function"?n(a.filters):n}))),setSelectedNodeId:(s,n)=>e(r=>at(r,s,a=>({...a,selectedNodeId:n}))),setFocusedNodeId:(s,n)=>e(r=>at(r,s,a=>({...a,focusedNodeId:n}))),setTrunkCollapseEnabled:(s,n)=>e(r=>at(r,s,a=>({...a,trunkCollapseEnabled:n,expandedTrunkSegmentIds:n?a.expandedTrunkSegmentIds:[]}))),toggleExpandTrunkSegment:(s,n)=>e(r=>at(r,s,a=>{const u=a.expandedTrunkSegmentIds.includes(n);return{...a,expandedTrunkSegmentIds:u?a.expandedTrunkSegmentIds.filter(i=>i!==n):[...a.expandedTrunkSegmentIds,n]}})),toggleCollapseBranch:(s,n)=>e(r=>at(r,s,a=>{const u=a.collapsedBranchIds.includes(n);return{...a,collapsedBranchIds:u?a.collapsedBranchIds.filter(i=>i!==n):[...a.collapsedBranchIds,n]}})),setCamera:(s,n,r=!0)=>e(a=>{const u=a.byRepo[s];return u&&u.camera&&u.cameraInitialized===r&&Math.abs(u.camera.x-n.x)<1e-6&&Math.abs(u.camera.y-n.y)<1e-6&&Math.abs(u.camera.zoom-n.zoom)<1e-6?a:at(a,s,i=>({...i,camera:{x:n.x,y:n.y,zoom:n.zoom},cameraInitialized:r}))}),setLockedPosition:(s,n,r)=>e(a=>{const i={...a.lockedPositionsByRepo[s]??pn(s),[n]:{x:Math.round(r.x),y:Math.round(r.y)}};return gn(s,i),{lockedPositionsByRepo:{...a.lockedPositionsByRepo,[s]:i}}}),autoArrange:s=>e(n=>(gn(s,{}),{...at(n,s,r=>({...r,camera:null,cameraInitialized:!1,arrangeSeq:r.arrangeSeq+1})),lockedPositionsByRepo:{...n.lockedPositionsByRepo,[s]:{}}})),addQuickPhrase:s=>{const n=s.trim().slice(0,zn);if(!n)return!1;let r=!1;return e(a=>{if(a.quickPhrases.includes(n)||a.quickPhrases.length>=Dn)return a;const u=[...a.quickPhrases,n];return Ht(u),r=!0,{quickPhrases:u}}),r},removeQuickPhrase:s=>e(n=>{if(s<0||s>=n.quickPhrases.length)return n;const r=n.quickPhrases.filter((a,u)=>u!==s);return Ht(r),{quickPhrases:r}}),resetQuickPhrases:()=>e(()=>{const s=[...Lt];return Ht(s),{quickPhrases:s}}),setShowPhaseSummary:s=>e(()=>(yn(s),{showPhaseSummary:s})),toggleShowPhaseSummary:()=>e(s=>{const n=!s.showPhaseSummary;return yn(n),{showPhaseSummary:n}}),resetAll:()=>{Bs.clear(),e({byRepo:{},lockedPositionsByRepo:{},quickPhrases:xn(),showPhaseSummary:bn()})}})),Ds=4e3,zs=[],Hn="(?:本轮用户需求原文|需求由来|AI\\s*改进结论与说明|核心结论与改善要点|技术溯源与提交明细|视觉验收与页面快照)",Fs=new RegExp(`^\\s*(?:0?\\d+\\s*[·•..、-]\\s*)?${Hn}\\s*$`),Hs=new RegExp(`^\\s*0?\\d+\\s*[·•..、-]\\s*${Hn}\\s*`);function Ks(e){const s=e.replace(/\r\n?/g,`
5
+ `).split(`
6
+ `),n=[];for(const r of s){if(Fs.test(r))continue;const a=r.replace(Hs,"");a.trim().length===0&&r.trim().length>0||n.push(a)}return n.join(`
7
+ `).replace(/\n{3,}/g,`
8
+
9
+ `).trim()}function wn(e){return e?e instanceof Element?e:e.parentElement:null}function Ws(e,s,n){const r=wn(n.startContainer),a=wn(n.endContainer);if(!r||!a||!e.contains(r)||!e.contains(a))return!1;const u=Array.from(s.querySelectorAll('[data-chronicle-selectable="true"]'));if(u.length===0)return!1;const i=r.closest('[data-chronicle-selectable="true"]'),d=a.closest('[data-chronicle-selectable="true"]');if(i&&s.contains(i)||d&&s.contains(d))return!0;if(typeof n.intersectsNode=="function")try{if(u.some(l=>n.intersectsNode(l)))return!0}catch{}const m=n.commonAncestorContainer;return m&&typeof m.contains=="function"?u.some(l=>m.contains(l)):!1}function qs(e,s,n){var u;if(n.length===0)return null;const r=Array.from(new Set([...((u=e.requirementMeta)==null?void 0:u.linkedRefs)??[],e.ref].map(i=>i==null?void 0:i.trim()).filter(i=>!!i)));if(r.length===0)return null;const a=new Map;for(const i of n)a.set(i.ref,i);for(const i of r){const d=a.get(i);if(d&&!d.isBase&&d.ref!==s)return d}for(const i of r){const d=a.get(i);if(d)return d}return null}function kn(e,s){return e.ref&&e.ref!=="__working__"?e.ref:s||"main"}function vn(e){var n;const s=((n=e.sha)==null?void 0:n.trim())||"";if(!(!s||s.startsWith("working-")))return/^[0-9a-f]{7,40}$/i.test(s)?s:void 0}function Xs(e,s,n,r){var d,m;const a=r?r.slice(0,7):e.shortSha||"HEAD",i=[s==="fork"?`请基于节点「${e.title}」(基准分支 ${n},提交 ${a})派生新分支进行探索与实现:`:`请基于节点「${e.title}」(分支 ${n},提交 ${a})继续推进迭代:`];if(yt(e)){const l=((m=(d=e.requirementMeta)==null?void 0:d.userPrompt)==null?void 0:m.trim())||e.requirementOrigin;i.push(`
10
+ 【需求由来】
11
+ ${l}`)}else e.summary&&i.push(`
12
+ 【改动说明】
13
+ ${e.summary}`);return e.improvements.length>0?i.push(`
14
+ 【已有改进点】
15
+ ${e.improvements.map((l,x)=>`${x+1}. ${l}`).join(`
16
+ `)}`):yt(e)&&e.summary&&i.push(`
17
+ 【阶段摘要】
18
+ ${e.summary}`),i.join(`
19
+ `)}const Gs=({node:e,baseBranch:s,phase:n,hasForkChildren:r=!1,isFocused:a=!1,onFocusNode:u,onOpenTrace:i,onClose:d})=>{var H,F,p,I;const m=Xt(h=>{var S;return((S=h.repo)==null?void 0:S.branches)??zs}),l=o.useMemo(()=>qs(e,s,m),[e,s,m]),x=o.useMemo(()=>{if(e.evidence.comparePair)return e.evidence.comparePair;if(!l)return;const h=l.parentBranch||(e.parentRef&&e.parentRef!==l.ref?e.parentRef:s)||s;if(!(!h||h===l.ref))return{baseRef:h,targetRef:l.ref}},[e.evidence.comparePair,e.parentRef,l,s]),y=!!((H=e.summary)!=null&&H.trim()||e.improvements.length>0||e.evidence.reportMarkdown),[M,$]=o.useState(!0),[k,w]=o.useState(!1),[T,j]=o.useState(!y||!e.sha&&!l),[D,A]=o.useState(!1),[G,R]=o.useState(!1),[f,B]=o.useState(null),[g,V]=o.useState(!1),[ae,L]=o.useState(""),ie=o.useRef(null),te=o.useRef(null),ce=o.useRef(null),U=o.useRef(!1),Ce=o.useRef(e.id);o.useEffect(()=>{Ce.current!==e.id&&(Ce.current=e.id,w(!1),A(!1),R(!1),B(null),V(!1),j(!y||!e.sha&&!l))},[e.id,y,e.sha,l]);const K=ye(h=>h.quickPhrases),Y=ye(h=>h.addQuickPhrase),se=ye(h=>h.removeQuickPhrase),Te=ye(h=>h.resetQuickPhrases),re=en(e.origin),Z=Ut[e.status],ue=Jt[e.impactCategory],we=yt(e),ke=e.branchMeta,_=e.requirementMeta,Pe=we&&!!_&&e.origin.conversationSource!=="git-inferred",Ne=((F=e.subtitle)==null?void 0:F.trim())||"",be=!!(e.rawTitle&&e.rawTitle.trim()&&e.rawTitle.trim()!==e.title.trim()),De=((p=_==null?void 0:_.userPrompt)==null?void 0:p.trim())||e.requirementOrigin||"",Se=De?De.split(/\r?\n/).length:0,he=De.length>180||Se>4,_e=he&&!k,Ie=((I=_==null?void 0:_.linkedRefs)==null?void 0:I[0])||e.ref,me=e.evidence.changedFiles??[],We=D?me:me.slice(0,10),ne=e.evidence.commitShas.map((h,S)=>{var O;return{sha:h,message:((O=e.evidence.commitMessages)==null?void 0:O[S])||""}}),ze=G?ne:ne.slice(0,8),pe=o.useCallback(()=>{var $e;const h=ie.current,S=te.current,O=($e=window.getSelection)==null?void 0:$e.call(window);if(!h||!S||!O||O.rangeCount===0||O.isCollapsed){B(null);return}const Q=O.getRangeAt(0);if(!Ws(h,S,Q)){B(null);return}const xe=Ks(O.toString());if(xe.length===0||xe.length>Ds){B(null);return}B(xe)},[]);o.useEffect(()=>{const h=()=>{U.current||ce.current&&document.activeElement instanceof Node&&ce.current.contains(document.activeElement)||pe()},S=()=>{U.current&&(U.current=!1,pe())},O=Q=>{var $e,Fe;const xe=Q.target;xe instanceof Node&&(($e=ce.current)!=null&&$e.contains(xe)||(Fe=te.current)!=null&&Fe.contains(xe)||(U.current=!1,B(null),V(!1)))};return document.addEventListener("selectionchange",h),document.addEventListener("pointerdown",O,!0),document.addEventListener("mousedown",O,!0),window.addEventListener("pointerup",S),window.addEventListener("mouseup",S),window.addEventListener("pointercancel",S),window.addEventListener("blur",S),()=>{document.removeEventListener("selectionchange",h),document.removeEventListener("pointerdown",O,!0),document.removeEventListener("mousedown",O,!0),window.removeEventListener("pointerup",S),window.removeEventListener("mouseup",S),window.removeEventListener("pointercancel",S),window.removeEventListener("blur",S)}},[pe]);const v=h=>{const S=x;if(!S)return;const O=is.getState();O.setCompareBaseRef(S.baseRef),O.setCompareTargetRef(S.targetRef),e.evidence.route&&O.setRoute(e.evidence.route),O.openBackendDiff(h),O.resolveTargetsForPair(S.baseRef,S.targetRef,!e.evidence.route)},W=()=>{const h=e.evidence.taskId;h&&(zt.getState().selectTask(h),os.getState().setTaskPanelOpen(!0))},oe=h=>{const S=kn(e,s),O=vn(e);zt.getState().openComposer({sourceRef:S,sourceSha:O,regions:[],route:e.evidence.route,defaultKind:"code-change",defaultTitle:h==="fork"?`派生新分支:${e.title}`:`基于 ${e.title} 继续迭代`,defaultInstruction:Xs(e,h,S,O)})},ge=h=>{var $e,Fe;if(!f)return;const S=kn(e,s),O=vn(e),Q=O?O.slice(0,7):e.shortSha||"HEAD",xe=h?`
20
+
21
+ 请重点:${h}`:`
22
+
23
+ 请基于以上引用内容继续分析并落实修改。`;zt.getState().openComposer({sourceRef:S,sourceSha:O,regions:[],route:e.evidence.route,defaultKind:"code-change",defaultTitle:h?`${h}:${e.title}`:`引用追问:${e.title}`,defaultInstruction:`引用自节点「${e.title}」(${S} @ ${Q}):
24
+
25
+ > ${f.replace(/\n/g,`
26
+ > `)}${xe}`}),B(null),V(!1);try{(Fe=($e=window.getSelection)==null?void 0:$e.call(window))==null||Fe.removeAllRanges()}catch{}},J=h=>{h.preventDefault(),Y(ae)&&L("")};return t.jsxs("aside",{ref:ie,className:"bl-ch-drawer","data-testid":"chronicle-detail-drawer","aria-label":"节点溯源详情",children:[t.jsxs("div",{className:"bl-ch-drawer-head",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"bl-ch-drawer-meta-row",children:[_&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"bl-ch-drawer-turn mono shrink-0","data-testid":"chronicle-drawer-turn-badge",children:["#",_.turnIndex]}),t.jsx("span",{className:"bl-ch-meta-sep shrink-0","aria-hidden":"true",children:"·"})]}),t.jsx("span",{className:"bl-ch-drawer-origin truncate","data-tone":re,children:tn(e.origin)}),e.origin.stale&&t.jsx("span",{className:"bl-ch-badge bl-ch-stale-chip shrink-0","data-tone":"stale","data-stale-badge":"true",children:"旧提交"}),t.jsx("span",{className:"bl-ch-meta-sep shrink-0","aria-hidden":"true",children:"·"}),t.jsxs("span",{className:"bl-ch-status-inline shrink-0","data-tone":Z.tone,children:[t.jsx("span",{className:"bl-ch-status-dot","aria-hidden":"true"}),t.jsx("span",{children:Z.label})]}),t.jsx("span",{className:"bl-ch-meta-sep shrink-0","aria-hidden":"true",children:"·"}),t.jsx("span",{className:"bl-ch-impact bl-ch-impact-plain shrink-0","data-impact":ue.tone,children:ue.label})]}),t.jsx("h2",{className:"bl-ch-drawer-title",title:Pe&&De||e.title,children:e.title}),Ne&&t.jsxs("p",{className:"bl-ch-drawer-subtitle truncate","data-testid":"chronicle-drawer-subtitle",title:Ne,children:[t.jsx("span",{className:"bl-ch-subtitle-prefix",children:"做了 · "}),t.jsx("span",{children:Ne})]}),t.jsxs("div",{className:"bl-ch-drawer-submeta mono truncate",children:[n&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:["阶段 ",n.order]}),t.jsx("span",{className:"bl-ch-meta-sep","aria-hidden":"true",children:"·"})]}),t.jsx("span",{children:Ie}),e.timestamp&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bl-ch-meta-sep","aria-hidden":"true",children:"·"}),t.jsx("span",{children:Tt(e.timestamp)})]}),e.origin.sourceChannel&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bl-ch-meta-sep","aria-hidden":"true",children:"·"}),t.jsx("span",{children:e.origin.sourceChannel})]})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[i&&t.jsx("button",{type:"button","data-testid":"chronicle-open-trace-btn",onClick:()=>i(e),className:"bl-pill-action text-[11.5px] whitespace-nowrap",title:"在执行轨迹检查器中查看该节点的详细步骤与工具调用",children:"查看执行轨迹"}),(r||a)&&u&&t.jsx("button",{type:"button","data-testid":"chronicle-drawer-focus-btn",onClick:()=>u(a?null:e.id),className:"bl-pill-action text-[11.5px] whitespace-nowrap",style:{color:a?"var(--accent)":void 0},children:a?"退出聚焦":"聚焦子树"}),t.jsx("button",{type:"button",onClick:d,"aria-label":"关闭溯源详情",className:"bl-pill-action bl-icon-pill flex items-center justify-center shrink-0 text-[15px]",children:"×"})]})]}),t.jsxs("div",{ref:te,className:"bl-ch-drawer-body",onPointerDown:()=>{U.current=!0},onMouseDown:()=>{U.current=!0},onKeyUp:pe,children:[we?t.jsxs(t.Fragment,{children:[t.jsxs("section",{className:"bl-ch-drawer-section",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1.5",children:[t.jsx("div",{className:"caps",children:_?"01 · 本轮用户需求原文":"01 · 需求由来"}),he&&t.jsx("button",{type:"button","data-testid":"chronicle-req-expand-btn","aria-expanded":k,onClick:()=>w(h=>!h),className:"bl-ch-req-expand-btn",children:k?"收起原文":"展开全文"})]}),t.jsx("div",{className:"bl-ch-callout text-[12.5px] leading-relaxed","data-clamped":_e?"true":"false","data-chronicle-selectable":"true","data-testid":"chronicle-drawer-requirement-text",children:t.jsx("div",{className:"bl-ch-callout-text whitespace-pre-wrap",children:De})})]}),t.jsxs("section",{className:"bl-ch-drawer-section","data-chronicle-selectable":"true","data-testid":"chronicle-drawer-core-summary",children:[t.jsx("div",{className:"caps mb-1.5",children:_?"02 · AI 改进结论与说明":"02 · 核心结论与改善要点"}),(_==null?void 0:_.outcomeSummary)&&_.outcomeSummary.trim()!==e.summary.trim()&&t.jsx("p",{className:"text-[12.5px] leading-relaxed mb-1.5 font-medium",style:{color:"var(--ink)"},children:_.outcomeSummary}),t.jsx("p",{className:"text-[12.5px] leading-relaxed",style:{color:"var(--ink)"},children:e.summary}),e.improvements.length>0&&t.jsx("ul",{className:"bl-ch-tl-bullets mt-2.5",children:e.improvements.map((h,S)=>t.jsx("li",{children:h},S))}),e.evidence.reportMarkdown&&t.jsxs("div",{className:"bl-ch-doc-box mt-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 pb-2 mb-2",style:{borderBottom:"1px solid var(--hair)"},children:[t.jsxs("span",{className:"text-[11.5px] font-semibold",children:["原开发 Agent 详尽文档",e.evidence.reportSource?`(${e.evidence.reportSource})`:""]}),t.jsx("button",{type:"button",onClick:()=>$(h=>!h),className:"text-[11px] sheet-link",children:M?"收起":"展开"})]}),M&&t.jsx("div",{"data-testid":"chronicle-report-markdown",children:t.jsx(dn,{content:e.evidence.reportMarkdown})})]})]})]}):t.jsx(t.Fragment,{children:t.jsxs("section",{className:"bl-ch-drawer-section","data-chronicle-selectable":"true","data-testid":"chronicle-drawer-core-summary",children:[t.jsx("div",{className:"caps mb-1.5",children:"01 · 核心结论与改善要点"}),t.jsx("p",{className:"text-[12.5px] leading-relaxed",style:{color:"var(--ink)"},children:e.summary}),e.improvements.length>0&&t.jsx("ul",{className:"bl-ch-tl-bullets mt-2.5",children:e.improvements.map((h,S)=>t.jsx("li",{children:h},S))}),e.evidence.reportMarkdown&&t.jsxs("div",{className:"bl-ch-doc-box mt-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 pb-2 mb-2",style:{borderBottom:"1px solid var(--hair)"},children:[t.jsxs("span",{className:"text-[11.5px] font-semibold",children:["原开发 Agent 详尽文档",e.evidence.reportSource?`(${e.evidence.reportSource})`:""]}),t.jsx("button",{type:"button",onClick:()=>$(h=>!h),className:"text-[11px] sheet-link",children:M?"收起":"展开"})]}),M&&t.jsx("div",{"data-testid":"chronicle-report-markdown",children:t.jsx(dn,{content:e.evidence.reportMarkdown})})]}),t.jsx("p",{className:"bl-ch-unrecorded-footnote","data-testid":"chronicle-unrecorded-requirement-hint",children:"原始需求未记录;上方标题与说明由系统结合提交记录与改动文件自动整理"})]})}),t.jsxs("section",{className:"bl-ch-drawer-section bl-ch-tech-section",children:[t.jsxs("button",{type:"button",className:"bl-ch-tech-toggle","data-testid":"chronicle-tech-details-toggle","aria-expanded":T,onClick:()=>j(h=>!h),children:[t.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[t.jsx("div",{className:"caps",children:"技术溯源与提交明细"}),t.jsxs("div",{className:"bl-ch-tech-summary mono truncate",children:[e.ref,e.mergeBaseSha?` · ${e.mergeBaseSha.slice(0,7)} → `:" · ",e.shortSha||(e.sha?e.sha.slice(0,7):l?`分支 ${l.shortSha||l.ref}`:"无提交"),` · ${e.evidence.changedFilesCount} 文件`,ne.length>0?` · ${ne.length} 提交`:""]})]}),t.jsx("span",{className:"bl-ch-tech-chevron mono shrink-0","aria-hidden":"true",children:T?"▾":"▸"})]}),T&&t.jsxs("div",{className:"mt-2","data-testid":"chronicle-tech-details-panel",children:[e.sha?t.jsxs("div",{className:"bl-ch-coord-card",children:[be&&t.jsxs("div",{className:"bl-ch-coord-row","data-testid":"chronicle-raw-title",title:e.rawTitle,children:[t.jsx("span",{className:"bl-ch-coord-label",children:"原始标题"}),t.jsx("span",{className:"mono text-[11.5px] break-all text-right",children:e.rawTitle})]}),(_==null?void 0:_.sessionTitle)&&t.jsxs("div",{className:"bl-ch-coord-row","data-testid":"chronicle-drawer-session-title",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"来源会话"}),t.jsx("span",{className:"mono text-[11.5px] break-all text-right",children:_.sessionTitle})]}),t.jsxs("div",{className:"bl-ch-coord-row",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"分叉基线"}),t.jsxs("span",{className:"mono text-[11.5px] break-all",children:[e.parentRef," · ",t.jsx("code",{children:e.mergeBaseSha.slice(0,7)||"—"})]})]}),t.jsxs("div",{className:"bl-ch-coord-row",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"当前目标"}),t.jsxs("span",{className:"mono text-[11.5px] break-all",children:[e.ref," · ",t.jsx("code",{children:e.shortSha||e.sha.slice(0,7)})]})]}),e.mergedIntoRef&&t.jsxs("div",{className:"bl-ch-coord-row",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"合入去向"}),t.jsx("span",{className:"mono text-[11.5px]",children:e.mergedIntoRef})]}),_&&_.linkedRefs.length>0&&t.jsxs("div",{className:"bl-ch-coord-row","data-testid":"chronicle-drawer-linked-refs",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"关联分支"}),t.jsx("span",{className:"mono text-[11.5px] break-all text-right",children:_.linkedRefs.join(" · ")})]}),ke&&t.jsxs("div",{className:"bl-ch-coord-row","data-testid":"chronicle-drawer-branch-meta",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"聚合规模"}),t.jsxs("span",{className:"mono text-[11.5px] text-right",children:[ke.commitCount," 次提交",ke.absorbedTrunkCommits&&ke.absorbedTrunkCommits>0?`(含 ${ke.absorbedTrunkCommits} 历史提交)`:""]})]}),(ke==null?void 0:ke.tagNames)&&ke.tagNames.length>0&&t.jsxs("div",{className:"bl-ch-coord-row",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"版本标签"}),t.jsx("span",{className:"mono text-[11.5px]",children:ke.tagNames.join(", ")})]}),e.evidence.route&&t.jsxs("div",{className:"bl-ch-coord-row",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"关联页面"}),t.jsx("span",{className:"mono text-[11.5px]",children:e.evidence.route})]}),t.jsxs("div",{className:"bl-ch-coord-row",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"改动规模"}),t.jsxs("span",{className:"mono text-[11.5px]",children:[e.evidence.changedFilesCount," 个文件",ne.length>0?` · ${ne.length} 次提交`:_&&_.linkedCommitCount>0?` · 关联 ${_.linkedCommitCount} 次提交`:""]})]})]}):l?t.jsxs("div",{className:"bl-ch-coord-card text-[12px]","data-testid":"chronicle-live-branch-coord",children:[be&&t.jsxs("div",{className:"bl-ch-coord-row","data-testid":"chronicle-raw-title",title:e.rawTitle,children:[t.jsx("span",{className:"bl-ch-coord-label",children:"原始标题"}),t.jsx("span",{className:"mono text-[11.5px] break-all text-right",children:e.rawTitle})]}),(_==null?void 0:_.sessionTitle)&&t.jsxs("div",{className:"bl-ch-coord-row","data-testid":"chronicle-drawer-session-title",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"来源会话"}),t.jsx("span",{className:"mono text-[11.5px] break-all text-right",children:_.sessionTitle})]}),t.jsxs("div",{className:"bl-ch-coord-row",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"关联分支"}),t.jsxs("span",{className:"mono text-[11.5px] break-all",children:[l.ref,l.shortSha?t.jsxs(t.Fragment,{children:[" ","· ",t.jsx("code",{children:l.shortSha})]}):null]})]}),t.jsxs("div",{className:"bl-ch-coord-row",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"对比基线"}),t.jsx("span",{className:"mono text-[11.5px] break-all",children:(x==null?void 0:x.baseRef)||e.parentRef||s})]}),_&&_.linkedRefs.length>0&&t.jsxs("div",{className:"bl-ch-coord-row","data-testid":"chronicle-drawer-linked-refs",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"全部关联分支"}),t.jsx("span",{className:"mono text-[11.5px] break-all text-right",children:_.linkedRefs.join(" · ")})]}),t.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--muted)"},children:"该节点未绑定独立提交 SHA,当前关联分支仍在仓库中有效,可直接查看差异。"})]}):t.jsxs("div",{className:"bl-ch-coord-card text-[12px]",style:{color:"var(--muted)"},children:[be&&t.jsxs("div",{className:"bl-ch-coord-row","data-testid":"chronicle-raw-title",title:e.rawTitle,children:[t.jsx("span",{className:"bl-ch-coord-label",children:"原始标题"}),t.jsx("span",{className:"mono text-[11.5px] break-all text-right",children:e.rawTitle})]}),(_==null?void 0:_.sessionTitle)&&t.jsxs("div",{className:"bl-ch-coord-row","data-testid":"chronicle-drawer-session-title",children:[t.jsx("span",{className:"bl-ch-coord-label",children:"来源会话"}),t.jsx("span",{className:"mono text-[11.5px] break-all text-right",children:_.sessionTitle})]}),t.jsx("div",{className:"font-medium",style:{color:"var(--ink)"},children:"历史分支与提交已不可用"}),t.jsxs("div",{className:"mono text-[11px] mt-1",style:{color:"var(--faint)"},children:["原分支:",e.ref," · 基准:",e.parentRef]}),_&&_.linkedRefs.length>0&&t.jsxs("div",{className:"mono text-[11px] mt-1",style:{color:"var(--faint)"},"data-testid":"chronicle-drawer-linked-refs",children:["关联分支:",_.linkedRefs.join(" · "),_.linkedCommitCount>0?` · 关联 ${_.linkedCommitCount} 提交`:""]})]}),ne.length>0&&t.jsxs("div",{className:"mt-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--muted)"},children:["提交记录(",ne.length,")"]}),ne.length>8&&t.jsx("button",{type:"button",onClick:()=>R(h=>!h),className:"text-[11px] sheet-link",children:G?"收起":`展开全部 ${ne.length} 条`})]}),t.jsx("ul",{className:"bl-ch-commit-list",children:ze.map(h=>t.jsxs("li",{className:"bl-ch-commit-item",children:[t.jsx("code",{className:"mono shrink-0",children:h.sha.slice(0,7)}),t.jsx("span",{className:"truncate",title:h.message||h.sha,children:h.message||"(无提交说明)"})]},h.sha))})]}),me.length>0&&t.jsxs("div",{className:"mt-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--muted)"},children:["变动文件清单(",me.length,")"]}),me.length>10&&t.jsx("button",{type:"button",onClick:()=>A(h=>!h),className:"text-[11px] sheet-link",children:D?"收起":`展开全部 ${me.length} 个`})]}),t.jsx("ul",{className:"bl-ch-file-list mono",children:We.map(h=>t.jsx("li",{className:"truncate",title:h,children:h},h))})]})]})]}),e.evidence.previewThumbnails&&e.evidence.previewThumbnails.length>0&&t.jsxs("section",{className:"bl-ch-drawer-section",children:[t.jsx("div",{className:"caps mb-1.5",children:"视觉验收与页面快照"}),t.jsx("div",{className:"grid grid-cols-2 gap-2",children:e.evidence.previewThumbnails.slice(0,4).map((h,S)=>{const O=as(h);return t.jsx("a",{href:O,target:"_blank",rel:"noopener noreferrer",className:"bl-ch-thumb-link",children:t.jsx("img",{src:O,alt:`${e.title} 快照 ${S+1}`,loading:"lazy",className:"w-full h-24 object-cover"})},h)})})]})]}),f&&t.jsxs("div",{ref:ce,className:"bl-ch-selection-bar","data-testid":"chronicle-selection-bar",onMouseDown:h=>{h.target instanceof HTMLInputElement||h.preventDefault()},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("span",{className:"text-[11px] truncate",style:{color:"var(--muted)"},children:["已选 ",f.length," 字:「",f.slice(0,28),f.length>28?"…":"","」"]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx("button",{type:"button","data-testid":"chronicle-selection-to-task",onClick:()=>ge(),className:"sheet-btn sheet-btn-primary h-6 px-2.5 text-[11.5px]",children:"带入任务"}),t.jsx("button",{type:"button","data-testid":"chronicle-quick-phrases-edit-btn",onClick:()=>V(h=>!h),className:"bl-pill-action text-[11px] px-2 py-0.5",children:g?"完成":"词条"})]})]}),t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:K.map((h,S)=>t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsxs("button",{type:"button","data-testid":`chronicle-quick-phrase-${S}`,onClick:()=>ge(h),className:"bl-ch-phrase-chip",children:["+ ",h]}),g&&t.jsx("button",{type:"button","aria-label":`删除快捷词 ${h}`,onClick:()=>se(S),className:"text-[11px] px-1 opacity-70 hover:opacity-100",children:"×"})]},h))}),g&&t.jsxs("form",{onSubmit:J,className:"flex items-center gap-1.5 mt-2",children:[t.jsx("input",{type:"text",value:ae,onChange:h=>L(h.target.value),placeholder:"新增快捷补充词(最多16字)","data-testid":"chronicle-quick-phrase-input",className:"sheet-input h-7 text-[11.5px] flex-1"}),t.jsx("button",{type:"submit","data-testid":"chronicle-quick-phrase-add-btn",className:"sheet-btn h-7 px-2 text-[11px]",children:"添加"}),t.jsx("button",{type:"button",onClick:Te,className:"text-[11px] sheet-link shrink-0",children:"恢复默认"})]})]}),t.jsxs("div",{className:"bl-ch-drawer-foot","data-testid":"chronicle-drawer-foot",children:[t.jsxs("div",{className:"bl-ch-drawer-foot-secondary",children:[x&&t.jsx("button",{type:"button","data-testid":"chronicle-launch-task-btn",onClick:()=>oe("continue"),className:"bl-pill-action bl-ch-foot-btn",title:"基于此节点发起任务",children:"发起任务"}),t.jsx("button",{type:"button","data-testid":"chronicle-fork-task-btn",onClick:()=>oe("fork"),className:"bl-pill-action bl-ch-foot-btn",title:"从此节点创建新分支继续开发",children:"创建分支"}),x&&t.jsx("button",{type:"button","data-testid":"chronicle-goto-code-diff",onClick:()=>v("code"),className:"bl-pill-action bl-ch-foot-btn",title:"查看代码差异",children:"代码差异"}),e.evidence.taskId&&t.jsx("button",{type:"button","data-testid":"chronicle-goto-task",onClick:W,className:"bl-pill-action bl-ch-foot-btn",title:`查看关联任务${e.evidence.taskStatus?`(${e.evidence.taskStatus})`:""}`,children:"关联任务"})]}),t.jsx("div",{className:"bl-ch-drawer-foot-primary",children:x?t.jsx("button",{type:"button","data-testid":"chronicle-goto-plain-diff",onClick:()=>v("plain"),className:"sheet-btn sheet-btn-primary bl-ch-foot-cta",title:"查看此次对比(AI 通俗总结)",children:"AI 对比"}):t.jsx("button",{type:"button","data-testid":"chronicle-launch-task-btn",onClick:()=>oe("continue"),className:"sheet-btn sheet-btn-primary bl-ch-foot-cta",title:"基于此节点发起任务",children:"发起任务"})})]})]})},Vs=`## 阶段一:核心架构搭建
27
+ 建立仓库主干与基础认证闭环
28
+
29
+ - feat/auth:实现本地 Mock 免登与会话同步,解决多分支预览频繁跳登录问题
30
+ - main:初始化基础工程骨架并建立基线标签`,Ys=({submitting:e,canClearPrivate:s,isRepoFileSource:n=!1,onSubmit:r,onClear:a,onClose:u})=>{const[i,d]=o.useState("开发 Agent / 手动补充"),[m,l]=o.useState(""),[x,y]=o.useState(""),[M,$]=o.useState(null),k=async w=>{w.preventDefault();const T=m.trim(),j=x.trim();if(!T&&!j){$("请至少填写「项目总览」或「历程 Markdown 文档」中的一项。");return}$(null),await r({agentName:i.trim()||void 0,overview:T||void 0,markdown:j||void 0})&&(l(""),y(""),u())};return t.jsxs("form",{onSubmit:w=>void k(w),className:"bl-ch-submit-panel","data-testid":"chronicle-submit-form",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 mb-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[13.5px] font-semibold",children:"录入 / 更新原开发 Agent 历程档案"}),t.jsx("div",{className:"text-[11.5px] mt-0.5",style:{color:"var(--muted)"},children:"写入本地私有存储(不污染业务仓库),优先于内置 AI 与静态 Git 展示;支持直接粘贴 Markdown 阶段脉络(`##` 阶段 + `- 分支/标题:内容`)。"})]}),t.jsx("button",{type:"button",onClick:u,"aria-label":"收起录入表单",className:"bl-pill-action bl-icon-pill flex items-center justify-center shrink-0",children:"×"})]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[t.jsxs("label",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"caps",children:"来源 Agent 名称"}),t.jsx("input",{type:"text",value:i,onChange:w=>d(w.target.value),placeholder:"例如:Claude Code / Codex / 产品负责人",className:"sheet-input h-8 text-[12.5px]"})]}),t.jsxs("label",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"caps",children:"项目演进总览(可选)"}),t.jsx("input",{type:"text",value:m,onChange:w=>l(w.target.value),placeholder:"一句话概括从初始版本到当前的演进脉络",className:"sheet-input h-8 text-[12.5px]"})]})]}),t.jsxs("label",{className:"flex flex-col gap-1 mt-3",children:[t.jsx("span",{className:"caps",children:"阶段与分支历程(Markdown)"}),t.jsx("textarea",{rows:5,value:x,onChange:w=>y(w.target.value),placeholder:Vs,className:"bl-ch-textarea mono text-[12px]"})]}),M&&t.jsx("div",{className:"text-[12px] mt-2",style:{color:"var(--accent)"},children:M}),t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mt-3",children:[t.jsx("div",{children:s?t.jsx("button",{type:"button",disabled:e,onClick:()=>void a(),"data-testid":"chronicle-clear-private-btn",className:"bl-pill-action text-[12px] font-medium",style:{color:"var(--accent)"},children:"清除私有提交"}):n?t.jsx("span",{className:"text-[11.5px]",style:{color:"var(--muted)"},"data-testid":"chronicle-repo-file-readonly-hint",children:"当前历程来自仓内 `.branch-lens/chronicle.*` 文件(只读);此处保存将写入本地私有覆盖。"}):null}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:u,className:"sheet-btn",children:"取消"}),t.jsx("button",{type:"submit",disabled:e,"data-testid":"chronicle-submit-btn",className:"sheet-btn sheet-btn-primary",children:e?"保存中…":"保存并刷新历程"})]})]})]})},Zs=.2,Qs=4,Us=.0015,Zt=16,Js=65,At=96,er=.75,tr=1.15,nr=.85,Nn=1.15,sr=.95,rr=1.25,ar=1.05,ir=1,or=Object.freeze({slow:.6,standard:1,fast:1.6});function Ye(e){return Number.isFinite(e)?Math.min(Qs,Math.max(Zs,e)):1}function Kn(e,s,n){const r=Ye(e.zoom);return{x:(s-e.x)/r,y:(n-e.y)/r}}function Qt(e,s,n){const r=Kn(e,s,n);return{localX:s,localY:n,worldX:r.x,worldY:r.y}}function wt(e,s,n){const r=Ye(s);return r===e.zoom?e:{x:n.localX-n.worldX*r,y:n.localY-n.worldY*r,zoom:r}}function cr(e,s){const n=e.deltaMode??0,r=e.deltaY,a=n===1?Zt:n===2?Math.max(1,s):1,u=r*a;return Number.isFinite(u)?u:0}function lr(e,s){const n=e.deltaMode??0,r=n===1?Zt:n===2?Math.max(1,s.width):1,a=n===1?Zt:n===2?Math.max(1,s.height):1;let u=Number.isFinite(e.deltaX??0)?(e.deltaX??0)*r:0,i=Number.isFinite(e.deltaY)?e.deltaY*a:0;return e.shiftKey&&u===0&&(u=i,i=0),{x:u,y:i}}function dr(e,s,n="standard"){if(!Number.isFinite(s)||s===0)return Ye(e);const r=or[n]??1;return Ye(e*Math.exp(-s*Us*r))}function ur(e,s,n){const r=Ye(s.targetZoom),a=Ye(e.zoom),u=Math.min(64,Math.max(0,Number.isFinite(n)?n:0)),i=Math.log(r/a);if(Math.abs(i)<.001)return{camera:wt(e,r,s.anchor),done:!0};const d=a*Math.exp(i*(1-Math.exp(-u/Js))),m=Ye(d),l=m===r||Math.abs(Math.log(r/m))<.001;return{camera:wt(e,l?r:m,s.anchor),done:l}}function _t(e,s,n=0){if(s.width<=0||s.height<=0)return null;const r=Ye(e.zoom);return{left:-e.x/r-n,right:(s.width-e.x)/r+n,top:-e.y/r-n,bottom:(s.height-e.y)/r+n}}function hr(e,s,n=At){if(e.length===0||s.width<=0||s.height<=0)return null;let r=1/0,a=1/0,u=-1/0,i=-1/0;for(const M of e)r=Math.min(r,M.x),a=Math.min(a,M.y),u=Math.max(u,M.x+M.width),i=Math.max(i,M.y+M.height);const d=Math.max(1,u-r),m=Math.max(1,i-a),l=Math.max(1,s.width-n),x=Math.max(1,s.height-n),y=Ye(Math.min(l/d,x/m));return{x:s.width/2-(r+u)/2*y,y:s.height/2-(a+i)/2*y,zoom:y}}function mr(e,s,n){const r=Ye(n);return{x:s.width/2-(e.x+e.width/2)*r,y:s.height/2-(e.y+e.height/2)*r,zoom:r}}function Wn(e,s,n,r){const a=Ye(n),u=r?(r.left+r.right)/2:s.width/2,i=r?(r.top+r.bottom)/2:s.height/2;return{x:u-(e.x+e.width/2)*a,y:i-(e.y+e.height/2)*a,zoom:a}}function jn(e){const s=Ye(e);return s<nr?sr:s>rr?ar:s>Nn?Nn:s}function fr(e,s,n={}){if(e.length===0||s.width<=0||s.height<=0)return null;const r=n.safeArea?n.safeArea.left:0,a=n.safeArea?n.safeArea.right:s.width,u=n.safeArea?n.safeArea.top:0,i=n.safeArea?n.safeArea.bottom:s.height,d=Math.max(1,a-r),m=Math.max(1,i-u),l=n.pad??At,x=n.minZoom??er,y=n.maxZoom??tr;let M=1/0,$=1/0,k=-1/0,w=-1/0;for(const f of e)M=Math.min(M,f.x),$=Math.min($,f.y),k=Math.max(k,f.x+f.width),w=Math.max(w,f.y+f.height);const T=Math.max(1,k-M),j=Math.max(1,w-$),D=Math.max(1,d-l),A=Math.max(1,m-l),G=Math.min(D/T,A/j),R=Ye(Math.min(y,Math.max(x,G)));return{x:(r+a)/2-(M+k)/2*R,y:(u+i)/2-($+w)/2*R,zoom:R}}function pr(e,s){return e.x+e.width>s.left&&e.x<s.right&&e.y+e.height>s.top&&e.y<s.bottom}function gr(e,s,n,r,a={}){if(r){const k=n.find(w=>w.id===r);if(k)return Wn(k.rect,s,1,a.safeArea)}const u=Qt(e,s.width/2,s.height/2),i=wt(e,1,u);if(n.length===0)return i;const d=Math.min(32,s.width*.1),m=Math.min(32,s.height*.1),l=_t(i,s,0);if(l){const k={left:l.left+d,right:l.right-d,top:l.top+m,bottom:l.bottom-m};if(n.some(w=>pr(w.rect,k)))return i}const x=Kn(e,s.width/2,s.height/2);let y=null,M=1/0;for(const k of n){const w=k.rect.x+k.rect.width/2,T=k.rect.y+k.rect.height/2,j=w-x.x,D=T-x.y,A=j*j+D*D;A<M&&(M=A,y=k)}const $=y??(a.fallbackFocusNodeId?n.find(k=>k.id===a.fallbackFocusNodeId):void 0)??n[n.length-1];return mr($.rect,s,1)}function xr(e,s,n,r={}){if(e.length===0||n.width<=0||n.height<=0)return null;const a=Ye(r.zoom??ir),u=[...e.map(g=>g.rect),...s];let i=r.focusNodeId?e.find(g=>g.id===r.focusNodeId):void 0;if(!i){i=e[e.length-1];for(const g of e)g.rect.x+g.rect.width>=i.rect.x+i.rect.width&&(i=g)}let d=1/0,m=1/0,l=-1/0,x=-1/0;for(const g of u)d=Math.min(d,g.x),m=Math.min(m,g.y),l=Math.max(l,g.x+g.width),x=Math.max(x,g.y+g.height);const y=Math.max(1,(l-d)*a),M=Math.max(1,(x-m)*a),$=i.rect.width*a,k=i.rect.height*a;let w;if(y<=n.width-96)w=Math.round(48-d*a);else{const g=Math.min(96,Math.max(40,n.width*.1)),V=n.width-g-(i.rect.x+i.rect.width)*a,ae=48-d*a;w=Math.round(Math.min(V,ae))}const T=Math.min(16,Math.max(0,(n.width-$)/2));w+i.rect.x*a<T?w=Math.round(T-i.rect.x*a):w+(i.rect.x+i.rect.width)*a>n.width-T&&(w=Math.round(n.width-T-(i.rect.x+i.rect.width)*a));const j=i.rect.y+i.rect.height/2,D=n.height>260?(n.height-44)/2:n.height/2,A=Math.round(D-j*a);let G=M<=n.height-96?A:Math.round(Math.min(A,32-m*a));const R=Math.min(24,Math.max(0,(n.height-k)/2)),f=Math.min(56,Math.max(0,n.height-k-R)),B=Math.max(R+k,n.height-f);return G+i.rect.y*a<R?G=Math.round(R-i.rect.y*a):G+(i.rect.y+i.rect.height)*a>B&&(G=Math.round(B-(i.rect.y+i.rect.height)*a)),{x:w,y:G,zoom:a}}const mt=.55,It=128,bt=360,br=720,yr=80,wr=320,kr=640;function $t(e,s,n,r=0,a=mt){const u=s<a;return[r,u,n??"",Math.floor(e.left/It),Math.floor(e.right/It),Math.floor(e.top/It),Math.floor(e.bottom/It)].join("|")}function Kt(e,s,n,r){return e.position.x+n>=s.left&&e.position.x<=s.right&&e.position.y+r>=s.top&&e.position.y<=s.bottom}function vr(e){const{index:s,viewportBounds:n,zoom:r,cardWidth:a,cardHeight:u,edges:i,selectedId:d=null,revision:m=0,margin:l=bt,prefetchMargin:x=br,overviewZoom:y=mt,detailLimit:M=yr,overviewLimit:$=wr,edgeLimit:k=kr,queryBounds:w,includePrefetch:T=!0,pinnedIds:j,stableOrderById:D}=e,A=r<y,G=$t(n,r,d,m,y),R=w??{left:n.left-l,right:n.right+l,top:n.top-l,bottom:n.bottom+l},f=s.query(R),B=(n.left+n.right)/2,g=(n.top+n.bottom)/2,V=K=>(K.position.x+a/2-B)**2+(K.position.y+u/2-g)**2;f.sort((K,Y)=>Number(Kt(Y,n,a,u))-Number(Kt(K,n,a,u))||V(K)-V(Y));const ae=A?$:M,L=f.slice(0,ae),ie=new Set(L.map(K=>K.id));if(d&&!ie.has(d)&&ae>0){const K=f.find(Y=>Y.id===d);if(K){const Y=L.pop();Y&&ie.delete(Y.id),L.push(K),ie.add(K.id)}}if(j&&j.size>0)for(const K of j){if(ie.has(K))continue;const Y=s.get(K);if(Y){if(L.length>=ae&&ae>0)for(let se=L.length-1;se>=0;se-=1){const Te=L[se];if(Te.id!==d&&!j.has(Te.id)){L.splice(se,1),ie.delete(Te.id);break}}L.push(Y),ie.add(Y.id)}}if(D){const K=Y=>Y.position.x>=n.left&&Y.position.x+a<=n.right&&Y.position.y>=n.top&&Y.position.y+u<=n.bottom?0:Kt(Y,n,a,u)?1:2;L.sort((Y,se)=>K(Y)-K(se)||(D.get(Y.id)??0)-(D.get(se.id)??0))}let te=[];if(T&&!A){const K={left:n.left-x,right:n.right+x,top:n.top-x,bottom:n.bottom+x};te=s.query(K).filter(Y=>!ie.has(Y.id)).sort((Y,se)=>V(Y)-V(se)).slice(0,12).map(Y=>Y.id)}const ce=[],U=[];for(const K of i){const Y=ie.has(K.fromId),se=ie.has(K.toId);Y&&se?ce.push(K):(Y||se)&&U.push(K)}const Ce=ce.length>=k?ce.slice(0,k):[...ce,...U.slice(0,k-ce.length)];return{overview:A,mountIds:ie,mountedCards:L,prefetchIds:te,mountedEdges:Ce,totalNearby:f.length,limited:f.length>L.length,planKey:G}}const qn=ct.memo(({item:e,overview:s,selected:n,isLatest:r=!1,dimmed:a,searchMatch:u=!1,childCount:i,descendantCount:d,isCollapsed:m,isFocusedRoot:l,hasToggleCollapseBranch:x,hasFocusNode:y,suppressClickRef:M,onBeginPointerDown:$,onSelectNode:k,onToggleCollapseBranch:w,onFocusNode:T})=>{var Pe,Ne,be,De,Se,he,_e,Ie;const{node:j}=e,D=en(j.origin),A=Ut[j.status],G=Jt[j.impactCategory],R=yt(j),f=j.branchMeta,B=j.requirementMeta,g=()=>{M.current||k(j.id)},V=me=>{(me.key==="Enter"||me.key===" ")&&(me.preventDefault(),k(j.id))},ae=me=>{$(me,j.id,e.position)};if(s)return t.jsx("div",{role:"button",tabIndex:0,"data-chronicle-node-id":j.id,"data-overview-card":"true","data-selected":n?"true":"false","data-latest-node":r?"true":"false","data-dimmed":a?"true":"false","data-search-match":u?"true":"false","data-status":j.status,"data-origin-tone":D,"data-dragging":"false","data-locked":e.positionLocked?"true":"false","aria-pressed":n,onPointerDown:ae,onClick:g,onKeyDown:V,className:"bl-ch-node-card bl-ch-node-card-overview",style:{left:`${e.x}px`,top:`${e.y}px`,width:`${Xe}px`,height:`${Ae}px`},children:t.jsxs("div",{className:"bl-ch-node-card-inner bl-ch-node-card-inner-overview",children:[t.jsxs("div",{className:"flex items-center gap-2 w-full min-w-0",children:[t.jsx("span",{className:"bl-ch-overview-dot","data-tone":A.tone}),B&&t.jsxs("span",{className:"bl-ch-turn-badge mono shrink-0","data-testid":"chronicle-turn-badge",children:["#",B.turnIndex]}),t.jsx("span",{className:"bl-ch-node-title truncate flex-1 text-left",title:j.title,children:j.title}),m&&d>0&&t.jsxs("span",{className:"bl-ch-fold-count mono shrink-0",children:["+",d]})]}),t.jsx("div",{className:"bl-ch-node-ref mono truncate w-full text-left",children:j.ref})]})});const L=tn(j.origin),ie=R&&!!B&&j.origin.conversationSource!=="git-inferred",te=((Pe=j.subtitle)==null?void 0:Pe.trim())||"",ce=((Ne=B==null?void 0:B.userPrompt)==null?void 0:Ne.trim())||((be=j.requirementOrigin)==null?void 0:be.trim())||j.title,U=ie&&fn(j.title)||j.title,Ce=ie?((De=j.summary)==null?void 0:De.trim())||((Se=B==null?void 0:B.outcomeSummary)==null?void 0:Se.trim())||"":R?((he=B==null?void 0:B.userPrompt)==null?void 0:he.trim())||j.requirementOrigin:((_e=j.summary)==null?void 0:_e.trim())||j.title,K=Ce?fn(Ce)||Ce.trim():"",Y=j.origin.kind==="ai-synthesis"&&(!R||ie),se=ie?Y?"ai":"summary":R?"origin":Y?"ai":"summary",Te=se==="summary"&&/^改动/.test(K),re=se==="origin"?"由来 · ":se==="ai"?"AI 解读 · ":Te?"":"改动 · ",Z=(f==null?void 0:f.absorbedTrunkCommits)??0,ue=((Ie=B==null?void 0:B.linkedRefs)==null?void 0:Ie[0])||j.ref,we=B&&B.linkedRefs.length>1?B.linkedRefs.length-1:0,ke=!!(f&&f.commitCount>0),_=!!(!f&&B&&B.linkedCommitCount>0);return t.jsx("div",{role:"button",tabIndex:0,"data-chronicle-node-id":j.id,"data-overview-card":"false","data-selected":n?"true":"false","data-latest-node":r?"true":"false","data-dimmed":a?"true":"false","data-search-match":u?"true":"false","data-status":j.status,"data-origin-tone":D,"data-dragging":"false","data-locked":e.positionLocked?"true":"false","aria-pressed":n,onPointerDown:ae,onClick:g,onKeyDown:V,className:"bl-ch-node-card",style:{left:`${e.x}px`,top:`${e.y}px`,width:`${Xe}px`,height:`${Ae}px`},children:t.jsxs("div",{className:"bl-ch-node-card-inner","data-has-prompt-title":ie?"true":void 0,"data-has-subtitle":te?"true":void 0,children:[t.jsxs("div",{className:"bl-ch-card-row1 flex items-center justify-between gap-1.5 w-full min-w-0 shrink-0",children:[t.jsxs("div",{className:"bl-ch-card-meta-line flex items-center min-w-0 flex-1",children:[B&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"bl-ch-card-turn mono shrink-0","data-testid":"chronicle-turn-badge",title:B.sessionTitle?`会话:${B.sessionTitle}`:`第 ${B.turnIndex} 轮需求`,children:["#",B.turnIndex]}),t.jsx("span",{className:"bl-ch-meta-sep shrink-0","aria-hidden":"true",children:"·"})]}),t.jsx("span",{className:"bl-ch-card-origin truncate","data-tone":D,title:L,children:L}),j.origin.stale&&t.jsx("span",{className:"bl-ch-badge bl-ch-stale-chip shrink-0 ml-1","data-tone":"stale","data-stale-badge":"true",title:"该 Agent 说明基于旧提交生成",children:"旧提交"})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[r&&t.jsx("span",{className:"bl-ch-latest-pill shrink-0","data-testid":"chronicle-latest-badge",title:"当前最新演进节点",children:"最新"}),t.jsxs("span",{className:"bl-ch-status-inline shrink-0","data-tone":A.tone,children:[t.jsx("span",{className:"bl-ch-status-dot","aria-hidden":"true"}),t.jsx("span",{children:A.label})]})]})]}),t.jsxs("div",{className:"w-full min-w-0 text-left shrink-0",children:[t.jsx("div",{className:ie?"bl-ch-node-title bl-ch-node-title-prompt":"bl-ch-node-title truncate",title:ie?ce:j.title,children:U}),te&&t.jsxs("div",{className:"bl-ch-node-subtitle truncate","data-testid":"chronicle-node-subtitle",title:te,children:[t.jsx("span",{className:"bl-ch-subtitle-prefix",children:"做了 · "}),t.jsx("span",{children:te})]}),t.jsxs("div",{className:"bl-ch-node-ref mono flex items-center min-w-0",children:[t.jsxs("span",{className:"truncate",children:[B?ue:j.ref,we>0?` +${we}`:""]}),j.shortSha?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bl-ch-meta-sep shrink-0","aria-hidden":"true",children:"·"}),t.jsx("span",{className:"shrink-0",children:j.shortSha})]}):!ke&&!_?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bl-ch-meta-sep shrink-0","aria-hidden":"true",children:"·"}),t.jsx("span",{className:"shrink-0",children:"无提交"})]}):null,ke&&f&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bl-ch-meta-sep shrink-0","aria-hidden":"true",children:"·"}),t.jsxs("span",{className:"shrink-0","data-testid":"chronicle-branch-commits",title:Z>0?`本分支/里程碑共 ${f.commitCount} 次提交(含 ${Z} 次历史主干提交)`:`共聚合 ${f.commitCount} 次提交`,children:[f.commitCount," 提交"]})]}),_&&B&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bl-ch-meta-sep shrink-0","aria-hidden":"true",children:"·"}),t.jsxs("span",{className:"shrink-0","data-testid":"chronicle-req-commits",title:`本轮需求关联 ${B.linkedCommitCount} 次代码提交`,children:[B.linkedCommitCount," 提交"]})]})]})]}),K&&t.jsxs("p",{className:"bl-ch-node-origin min-h-0","data-single-line":ie&&te?"true":void 0,title:K,children:[re&&t.jsx("span",{className:"bl-ch-origin-prefix-inline","data-tone":se,children:re}),t.jsx("span",{children:K})]}),t.jsxs("div",{className:"flex items-center justify-between gap-1.5 w-full mt-auto pt-1 text-[11px] shrink-0",children:[t.jsxs("div",{className:"bl-ch-card-foot-meta flex items-center min-w-0",children:[t.jsx("span",{className:"bl-ch-impact bl-ch-impact-plain shrink-0","data-impact":G.tone,children:G.label}),t.jsx("span",{className:"bl-ch-meta-sep shrink-0","aria-hidden":"true",children:"·"}),Z>0?t.jsxs("span",{className:"mono truncate","data-testid":"chronicle-absorbed-commits",title:`此里程碑节点吸收了 ${Z} 个前置裸主干提交`,children:["含 ",Z," 历史提交"]}):t.jsxs("span",{className:"mono truncate",children:[j.evidence.changedFilesCount," 文件"]})]}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[i>0&&x&&t.jsx("button",{type:"button","data-card-action":"collapse","data-testid":`chronicle-collapse-btn-${j.id}`,"aria-expanded":!m,onClick:me=>{me.stopPropagation(),w(j.id)},className:"bl-ch-card-mini-btn mono","data-active":m?"true":"false",title:m?`展开已折叠的 ${d} 个后代分支`:`折叠 ${d} 个后代分支`,children:m?`+${d}`:"收起"}),(i>0||l)&&y&&t.jsx("button",{type:"button","data-card-action":"focus","data-testid":`chronicle-focus-btn-${j.id}`,"aria-pressed":l,onClick:me=>{me.stopPropagation(),T(l?null:j.id)},className:"bl-ch-card-mini-btn","data-active":l?"true":"false",title:l?"退出子树聚焦":"聚焦此节点及其派生子树",children:l?"取消聚焦":"聚焦"}),t.jsx("span",{className:"mono shrink-0",style:{color:"var(--faint)"},children:Rt(j.timestamp)})]})]})]})})});qn.displayName="ChronicleCard";const Xn=ct.memo(({item:e,onExpandTrunkSegment:s})=>{const{segment:n,x:r,y:a,kind:u}=e;return t.jsxs("button",{type:"button","data-testid":"chronicle-trunk-segment","data-segment-id":n.id,"data-segment-kind":u,onClick:i=>{i.stopPropagation(),s(n.id)},className:"bl-ch-trunk-segment-pill",style:{left:`${r}px`,top:`${a}px`},title:`已折叠 ${n.count} 个常规主干提交,点击原位展开`,children:[t.jsx("span",{className:"opacity-65",children:"···"}),t.jsxs("span",{className:"mono",children:[n.count," 个提交"]})]})});Xn.displayName="TrunkSegmentPill";const Gn=ct.memo(({mountedEdges:e,highlightedEdgeIds:s,hasSelection:n,edgeDragUpdaterRef:r})=>{const a=o.useRef(new Map),u=o.useRef(new Map);o.useLayoutEffect(()=>{const d=new Map,m=new Set;for(const l of e){m.add(l.id);let x=d.get(l.fromId);if(x||(x=[],d.set(l.fromId,x)),x.push(l),l.toId!==l.fromId){let y=d.get(l.toId);y||(y=[],d.set(l.toId,y)),y.push(l)}}u.current=d;for(const l of a.current.keys())m.has(l)||a.current.delete(l);return r.current=(l,x)=>{const y=u.current.get(l);if(!(!y||y.length===0))for(const M of y){const $=a.current.get(M.id);if(!$)continue;const k=M.fromId===l?x:M.from.position,w=M.toId===l?x:M.to.position;$.path&&$.path.setAttribute("d",An(k,w,Xe,Ae)),$.forkCircle&&M.fromId===l&&($.forkCircle.setAttribute("cx",String(k.x+Xe)),$.forkCircle.setAttribute("cy",String(k.y+Ae/2))),$.mergeCircle&&M.toId===l&&($.mergeCircle.setAttribute("cx",String(w.x)),$.mergeCircle.setAttribute("cy",String(w.y+Ae/2)))}},()=>{r.current=null}},[e,r]);const i=d=>{let m=a.current.get(d);return m||(m={path:null,forkCircle:null,mergeCircle:null},a.current.set(d,m)),m};return t.jsx(t.Fragment,{children:e.map(d=>{const{edge:m,from:l,to:x,spanning:y}=d,M=s.has(m.id),$=n&&!M,k=M||m.kind==="merge";return t.jsxs("g",{className:"bl-ch-svg-edge-group","data-edge-id":m.id,"data-edge-kind":m.kind,"data-spanning":y?"true":"false","data-highlighted":M?"true":"false","data-dimmed":$?"true":"false",children:[t.jsx("path",{ref:w=>{const T=i(m.id);T.path=w},d:d.path,fill:"none",className:"bl-ch-svg-edge",markerEnd:k?"url(#bl-ch-arrow-accent)":"url(#bl-ch-arrow-trunk)"}),m.kind==="fork"&&!y&&t.jsx("circle",{ref:w=>{const T=i(m.id);T.forkCircle=w},cx:l.position.x+Xe,cy:l.position.y+Ae/2,r:M?4:3,className:"bl-ch-svg-anchor"}),m.kind==="merge"&&!y&&t.jsx("circle",{ref:w=>{const T=i(m.id);T.mergeCircle=w},cx:x.position.x,cy:x.position.y+Ae/2,r:M?4.2:3.2,className:"bl-ch-svg-anchor bl-ch-svg-anchor-merge"})]},m.id)})})});Gn.displayName="EdgesLayer";const Nr=90,Cn=110,Et=80;function Sn(e,s){if(e.length!==s.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n].id!==s[n].id)return!1;return!0}function jr(e,s){if(e.length!==s.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n].phase.id!==s[n].phase.id)return!1;return!0}function Cr(e,s){if(e.length!==s.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n].segment.id!==s[n].segment.id)return!1;return!0}function In(e,s,n,r,a,u,i,d,m){const l=_t(r,a,0)??{left:0,right:e.width,top:0,bottom:e.height},x=`${s}:${i??""}`,y=$t(l,r.zoom,u,x,mt),M=Math.max(.2,r.zoom),$=Math.max(1,a.width/M),k=Math.max(1,a.height/M),w=-d/M,T=-m/M,j=Math.max(-$,Math.min($,w*Cn)),D=Math.max(-k,Math.min(k,T*Cn)),A={left:l.left-bt+Math.min(0,j),right:l.right+bt+Math.max(0,j),top:l.top-bt+Math.min(0,D),bottom:l.bottom+bt+Math.max(0,D)},G=vr({index:e.regionIndex,viewportBounds:l,queryBounds:A,zoom:r.zoom,cardWidth:Xe,cardHeight:Ae,edges:e.edges,selectedId:u,revision:x,includePrefetch:!1,pinnedIds:i?new Set([i]):void 0,stableOrderById:n}),R=e.phaseBands.filter(ae=>ae.x+ae.width>=A.left&&ae.x<=A.right),f=e.collapsedSegments.filter(ae=>ae.x+140>=A.left&&ae.x-140<=A.right&&ae.y+48>=A.top&&ae.y-48<=A.bottom),B=A.left<=it+48,g=Math.max(it,Math.floor(A.left/1024)*1024),V=Math.min(Math.max(it,e.width-20),Math.ceil(A.right/1024)*1024);return{snapshot:{layoutRef:e,plan:G,visiblePhaseBands:R,visibleCollapsedSegments:f,showLaneRail:B,guideX1:g,guideX2:V},bucketKey:y,queryBounds:A}}const Vn=ct.memo(({layout:e,showPhaseSummary:s=!0,selectedNodeId:n,latestNodeId:r=null,focusedNodeId:a,collapsedBranchIds:u,searchMatchIds:i,lineageNodeIds:d,lineageEdgeIds:m,wrapRef:l,viewportRef:x,stageRef:y,svgWorldGroupRef:M,stickyRailRef:$,cameraRef:k,viewportSizeRef:w,suppressClickRef:T,schedulerRef:j,edgeDragUpdaterRef:D,onRegionBadgeChange:A,onSyncCameraToDom:G,onLayoutCommitted:R,hasToggleCollapseBranch:f,hasFocusNode:B,onBeginCardPointerDown:g,onSelectNode:V,onFocusNode:ae,onToggleCollapseBranch:L,onExpandTrunkSegment:ie})=>{const te=o.useRef(0),ce=o.useRef(null);ce.current!==e&&(ce.current=e,te.current+=1);const U=o.useMemo(()=>{const v=new Map;return e.nodes.forEach((W,oe)=>v.set(W.id,oe)),v},[e]),[Ce,K]=o.useState(()=>({width:w.current.width,height:w.current.height})),Y=o.useRef(null),se=o.useRef(""),Te=o.useRef(null),re=o.useRef({vx:0,vy:0}),Z=o.useRef(0),ue=o.useRef(e),we=o.useRef(U),ke=o.useRef(n);ue.current=e,we.current=U,ke.current=n;const[_,Pe]=o.useState(()=>{const v=In(e,te.current,U,k.current,w.current,n,null,0,0);return se.current=v.bucketKey,Te.current=v.queryBounds,v.snapshot}),Ne=o.useRef(_);Ne.current=_;const be=o.useCallback((v,W,oe)=>{const ge=ue.current,J=_t(v,W,0),H=`${te.current}:${Y.current??""}`;if(!oe&&J&&$t(J,v.zoom,ke.current,H,mt)===se.current)return;const F=In(ge,te.current,we.current,v,W,ke.current,Y.current,re.current.vx,re.current.vy);se.current=F.bucketKey,Te.current=F.queryBounds;const p=Ne.current;p.layoutRef===F.snapshot.layoutRef&&p.plan.overview===F.snapshot.plan.overview&&p.plan.limited===F.snapshot.plan.limited&&p.showLaneRail===F.snapshot.showLaneRail&&p.guideX1===F.snapshot.guideX1&&p.guideX2===F.snapshot.guideX2&&Sn(p.plan.mountedCards,F.snapshot.plan.mountedCards)&&Sn(p.plan.mountedEdges,F.snapshot.plan.mountedEdges)&&jr(p.visiblePhaseBands,F.snapshot.visiblePhaseBands)&&Cr(p.visibleCollapsedSegments,F.snapshot.visibleCollapsedSegments)||(Ne.current=F.snapshot,Pe(F.snapshot))},[]),De=o.useCallback((v,W={})=>{re.current={vx:W.vx??0,vy:W.vy??0};const oe=w.current,ge=_t(v,oe,0),J=Ne.current.plan.overview,H=v.zoom<mt,F=J!==H,p=Te.current,I=!W.zooming&&ge!==null&&p!==null&&(ge.left<p.left+Et||ge.right>p.right-Et||ge.top<p.top+Et||ge.bottom>p.bottom-Et);if(W.immediate||F||I){Z.current!==0&&(window.clearTimeout(Z.current),Z.current=0),be(v,oe,!!(W.immediate||F));return}if(ge){const h=`${te.current}:${Y.current??""}`;if($t(ge,v.zoom,ke.current,h,mt)===se.current)return}Z.current===0&&(Z.current=window.setTimeout(()=>{Z.current=0,be(k.current,w.current,!1)},Nr))},[k,be,w]);o.useLayoutEffect(()=>(j.current={notifyCamera:De,notifyViewportSize:v=>{K(W=>W.width===v.width&&W.height===v.height?W:v),Z.current!==0&&(window.clearTimeout(Z.current),Z.current=0),be(k.current,v,!0)},setPinnedCardId:v=>{Y.current!==v&&(Y.current=v,v&&!Ne.current.plan.mountIds.has(v)&&be(k.current,w.current,!0))}},()=>{j.current=null,Z.current!==0&&(window.clearTimeout(Z.current),Z.current=0)}),[k,be,De,j,w]),o.useLayoutEffect(()=>{Z.current!==0&&(window.clearTimeout(Z.current),Z.current=0),be(k.current,w.current,!0)},[e,n,k,w,be]),o.useLayoutEffect(()=>{G(),R()},[e,G,R]),o.useLayoutEffect(()=>{G()},[_.visiblePhaseBands,s,G]),o.useLayoutEffect(()=>{var W,oe;const v=_.plan.overview?"true":"false";(W=l.current)==null||W.setAttribute("data-overview",v),(oe=x.current)==null||oe.setAttribute("data-overview",v),A({overview:_.plan.overview,limited:_.plan.limited,mountedCount:_.plan.mountedCards.length,totalCount:e.nodes.length})},[e.nodes.length,A,_.plan.limited,_.plan.mountedCards.length,_.plan.overview,x,l]),o.useEffect(()=>()=>{Z.current!==0&&(window.clearTimeout(Z.current),Z.current=0)},[]);const Se=!!n,he=e.phaseHeaderHeight,{plan:_e,visiblePhaseBands:Ie,visibleCollapsedSegments:me,showLaneRail:We,guideX1:ne,guideX2:ze}=_,pe=o.useMemo(()=>me.filter(v=>(v.kind==="leading"||v.kind==="trailing")&&v.lineStartX!==void 0&&v.lineEndX!==void 0),[me]);return t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"bl-ch-svg","data-testid":"chronicle-swimlane-svg",viewBox:`0 0 ${Ce.width} ${Ce.height}`,"aria-label":"软件开发历程演进泳道图",children:[t.jsxs("defs",{children:[t.jsx("marker",{id:"bl-ch-arrow-trunk",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:t.jsx("path",{d:"M 1 2 L 9 5 L 1 8 z",fill:"currentColor"})}),t.jsx("marker",{id:"bl-ch-arrow-accent",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:t.jsx("path",{d:"M 1 2 L 9 5 L 1 8 z",fill:"var(--accent)"})})]}),t.jsxs("g",{ref:M,className:"bl-ch-svg-world",children:[Ie.map(v=>{const W=e.phaseBands.indexOf(v);return t.jsx("rect",{x:v.x,y:he+6,width:v.width,height:Math.max(0,e.height-he-18),rx:14,className:"bl-ch-svg-phase-band","data-alt":W%2===1?"true":"false"},`band-${v.phase.id}`)}),ze>ne&&Array.from({length:e.laneCount},(v,W)=>{const oe=he+20+W*(Ae+pt)+Ae/2;return t.jsx("line",{x1:ne,y1:oe,x2:ze,y2:oe,className:"bl-ch-svg-lane-guide","data-trunk":e.hasTrunkLane&&W===0?"true":"false"},`guide-${W}`)}),pe.map(v=>t.jsx("line",{x1:v.lineStartX,y1:v.y,x2:v.lineEndX,y2:v.y,className:"bl-ch-svg-trunk-guide","data-trunk-guide-kind":v.kind,"data-segment-id":v.segment.id},`trunk-guide-${v.segment.id}`)),t.jsx(Gn,{mountedEdges:_e.mountedEdges,highlightedEdgeIds:m,hasSelection:Se,edgeDragUpdaterRef:D})]})]}),t.jsxs("div",{ref:y,className:"bl-ch-canvas-stage","data-testid":"chronicle-canvas-transform",style:{width:"0px",height:"0px",transformOrigin:"0 0"},children:[We&&t.jsx("div",{className:"bl-ch-lane-rail",style:{width:`${it-10}px`,height:`${e.height}px`},"aria-hidden":"true",children:e.laneLabels.map((v,W)=>{const oe=he+20+W*(Ae+pt);return t.jsxs("div",{className:"bl-ch-lane-label","data-trunk":e.hasTrunkLane&&W===0?"true":"false",style:{top:`${oe+Ae/2-14}px`},title:v,children:[t.jsx("span",{className:"bl-ch-lane-dot"}),t.jsx("span",{className:"truncate",children:v})]},v)})}),Ie.map(v=>{var F,p;const W=e.phaseBands.indexOf(v),oe=((F=v.phase.summary)==null?void 0:F.trim())||"",ge=s&&!!oe,J=((p=v.phase.goal)==null?void 0:p.trim())||"",H=!!(J&&(!ge||J!==oe));return t.jsx("div",{className:"bl-ch-phase-head",style:{left:`${v.x}px`,width:`${v.width}px`,height:`${he-6}px`},"data-phase-band":v.phase.id,"data-has-summary":ge?"true":"false",children:t.jsxs("div",{className:"bl-ch-phase-head-inner","data-phase-sticky-inner":"true","data-band-x":v.x,"data-band-w":v.width,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:"bl-ch-phase-ord mono",children:String(v.phase.order||W+1).padStart(2,"0")}),t.jsx("span",{className:"bl-ch-phase-title truncate",title:v.phase.title,children:v.phase.title})]}),t.jsxs("span",{className:"bl-ch-phase-count mono shrink-0",children:[v.nodeCount," 节点"]})]}),H&&t.jsx("p",{className:"bl-ch-phase-goal truncate shrink-0",title:J,children:J}),ge&&t.jsxs("p",{className:"bl-ch-phase-summary","data-testid":"chronicle-phase-summary",title:oe,children:[t.jsx("span",{className:"bl-ch-phase-summary-spark","aria-hidden":"true",children:"✦"}),t.jsx("span",{children:oe})]})]})},v.phase.id)}),me.map(v=>t.jsx(Xn,{item:v,onExpandTrunkSegment:ie},v.segment.id)),_e.mountedCards.map(v=>{const W=v.id,oe=n===W,ge=Se&&!d.has(W);return t.jsx(qn,{item:v,overview:_e.overview,selected:oe,isLatest:r===W,dimmed:ge,searchMatch:i?i.has(W):!1,childCount:e.childCounts.get(W)??0,descendantCount:e.descendantCounts.get(W)??0,isCollapsed:u.has(W),isFocusedRoot:a===W,hasToggleCollapseBranch:f,hasFocusNode:B,suppressClickRef:T,onBeginPointerDown:g,onSelectNode:V,onToggleCollapseBranch:L,onFocusNode:ae},W)})]}),t.jsx("div",{ref:$,className:"bl-ch-sticky-lane-rail","data-testid":"chronicle-sticky-lane-rail","data-visible":"false","data-placement":"lane-gutter","aria-hidden":"true",children:e.laneLabels.map((v,W)=>t.jsxs("div",{className:"bl-ch-sticky-lane-pill","data-lane-index":W,"data-trunk":e.hasTrunkLane&&W===0?"true":"false","data-in-bounds":"true",children:[t.jsx("span",{className:"bl-ch-lane-dot"}),t.jsx("span",{className:"truncate",children:v})]},`${W}:${v}`))})]})});Vn.displayName="ChronicleCanvasContent";const Yn=ct.memo(({registerBadgeUpdater:e})=>{const[s,n]=o.useState(null);return o.useLayoutEffect(()=>{e(r=>{n(a=>a&&a.overview===r.overview&&a.limited===r.limited&&a.mountedCount===r.mountedCount&&a.totalCount===r.totalCount?a:r)})},[e]),!s||!s.overview&&!s.limited?null:t.jsxs("span",{className:"bl-ch-region-pill mono","data-testid":"chronicle-region-status",children:[s.overview?"远景短卡":"视口渲染"," · ",s.mountedCount,"/",s.totalCount]})});Yn.displayName="ChronicleRegionBadge";const Sr=5,Ir=150,Er={width:1e3,height:640};function Wt(e){return e instanceof Element?e.closest("input, textarea, select")!==null||e.closest('[contenteditable]:not([contenteditable="false"])')!==null:!1}function Mr(){var e,s;try{return!!((s=(e=window.matchMedia)==null?void 0:e.call(window,"(prefers-reduced-motion: reduce)"))!=null&&s.matches)}catch{return!1}}function qt(e,s){return!e||!s?!1:Math.abs(e.x-s.x)<1e-6&&Math.abs(e.y-s.y)<1e-6&&Math.abs(e.zoom-s.zoom)<1e-6}function Rr({viewportRef:e,stageRef:s,svgWorldGroupRef:n,stickyRailRef:r,zoomPctTextRef:a,zoomPctBtnRef:u,schedulerRef:i,edgeDragUpdaterRef:d,repoKey:m="__standalone__",initialCamera:l,initialCameraInitialized:x,externalCamera:y,arrangeSeq:M,allCardRects:$,fitExtraRects:k=[],recentFocusNodeId:w=null,selectedNodeId:T,phaseHeaderHeight:j=Vt,onPersistCamera:D,onCommitCardDrag:A}){const G=l??{x:24,y:20,zoom:1},R=o.useRef(G),f=o.useRef(Er),B=o.useRef(null),g=o.useRef($),V=o.useRef(k),ae=o.useRef(w),L=o.useRef(T),ie=o.useRef(j),te=o.useRef(D),ce=o.useRef(A),U=o.useRef(!1),Ce=o.useRef(!1),K=o.useRef(!1),Y=`${m}:${M}`,se=o.useRef(Y),Te=o.useRef(m),re=o.useRef(M),Z=o.useRef(x),ue=o.useRef(!1),we=o.useRef(l),ke=o.useRef(-1),_=o.useRef(0),Pe=o.useRef(null),Ne=o.useRef(0),be=o.useRef(null),De=o.useRef(0),Se=o.useRef(0),he=o.useRef(null),_e=o.useRef(null),Ie=o.useRef(!1),me=o.useRef(T),We=o.useRef(null),ne=o.useRef({panning:!1,wheelPanning:!1,zooming:!1,cardDragging:!1}),ze=o.useRef(null);g.current=$,V.current=k,ae.current=w,L.current=T,ie.current=j,te.current=D,ce.current=A;const pe=o.useCallback(()=>{const b=e.current;if(!b)return;const C=ne.current,N=C.panning||C.wheelPanning||C.zooming||C.cardDragging;b.classList.toggle("is-interacting",N),b.classList.toggle("is-panning",C.panning),b.classList.toggle("is-wheel-panning",C.wheelPanning),b.classList.toggle("is-zooming",C.zooming),b.classList.toggle("is-card-dragging",C.cardDragging),b.setAttribute("data-panning",C.panning?"true":"false"),b.setAttribute("data-dragging-card",C.cardDragging?"true":"false"),b.setAttribute("data-space-pan",U.current?"true":"false")},[e]),v=o.useCallback((b,C=!1)=>{var ee,Ee;const N=s.current;N&&(N.style.transform=`translate(${b.x}px, ${b.y}px) scale(${b.zoom})`);const z=n.current;z&&z.setAttribute("transform",`matrix(${b.zoom} 0 0 ${b.zoom} ${b.x} ${b.y})`);const q=f.current,X=b.zoom>=mt&&q.width>=560&&b.x<-78*b.zoom,E=r==null?void 0:r.current;if(E){const le=X?"true":"false";if(E.setAttribute("data-visible",le),(ee=e.current)==null||ee.setAttribute("data-sticky-rail",le),X){const je=q.height-58,Oe=E.children;for(let ve=0;ve<Oe.length;ve+=1){const Me=Oe[ve],He=Me.getAttribute("data-lane-index"),nt=He!==null?Number(He):ve,Ge=ie.current+20+nt*(Ae+pt)-Ps,Ze=b.y+Ge*b.zoom,Ue=Ze>=10&&Ze<=je;Me.setAttribute("data-in-bounds",Ue?"true":"false"),Me.style.transform=`translate3d(0, ${Math.round(Ze-Rs/2)}px, 0)`}}}if(N){const le=N.getElementsByClassName("bl-ch-phase-head-inner");if(le.length>0){const Oe=Math.max(.2,b.zoom),ve=X?it+16:16,He=(Math.max(ve+180,q.width-16)-ve)/Oe,nt=(ve-b.x)/Oe;for(let Re=0;Re<le.length;Re+=1){const Ge=le[Re],Ze=Number(Ge.getAttribute("data-band-x")),Ue=Number(Ge.getAttribute("data-band-w"));if(!Number.isFinite(Ze)||!Number.isFinite(Ue))continue;const Ke=Math.max(0,Ue-28),ot=Math.round(Math.min(Ke,Math.max(220,Math.min(720,He)))),dt=Math.max(0,Ke-ot),kt=nt-(Ze+14),xt=Math.round(Math.max(0,Math.min(dt,kt)));Ge.style.width=`${ot}px`,Ge.style.transform=`translate3d(${xt}px, 0, 0)`}}}const fe=Math.round(b.zoom*100);if(fe!==ke.current){ke.current=fe;const le=`${fe}%`,Le=a.current;Le&&(Le.childNodes.length===1&&((Ee=Le.firstChild)==null?void 0:Ee.nodeType)===3?Le.firstChild.nodeValue=le:Le.textContent=le),u.current&&u.current.setAttribute("aria-label",`当前缩放 ${fe}%,点击恢复 100%`)}C&&e.current&&e.current.setAttribute("data-zoom",b.zoom.toFixed(3))},[s,r,n,e,u,a]),W=o.useCallback(()=>{v(R.current,!0)},[v]);o.useLayoutEffect(()=>{v(R.current,!1)},[j,v]);const oe=o.useCallback(()=>{const b=ze.current;b&&(b.fallbackTimer!==0&&window.clearTimeout(b.fallbackTimer),b.el.style.transform="",b.el.setAttribute("data-dragging","false"),ze.current=null)},[]),ge=o.useCallback(()=>{Se.current!==0&&(window.clearTimeout(Se.current),Se.current=0),ne.current.wheelPanning&&(ne.current.wheelPanning=!1,pe())},[pe]),J=o.useCallback(b=>{var N;if(ge(),b&&b!==se.current){ue.current=!1;return}const C=R.current;ue.current=!1,!(qt(C,we.current)&&Z.current)&&(we.current={x:C.x,y:C.y,zoom:C.zoom},Z.current=!0,(N=e.current)==null||N.setAttribute("data-zoom",C.zoom.toFixed(3)),te.current(C,!0))},[ge,e]),H=o.useCallback(()=>{_.current!==0&&(window.cancelAnimationFrame(_.current),_.current=0),Pe.current=null,Ne.current!==0&&(window.cancelAnimationFrame(Ne.current),Ne.current=0),be.current=null,ne.current.zooming&&(ne.current.zooming=!1,pe())},[pe]),F=o.useCallback((b,C={})=>{var N;R.current=b,v(b,!!C.persist),(N=i.current)==null||N.notifyCamera(b,{immediate:C.immediateRegion,zooming:C.zooming,vx:C.vx,vy:C.vy}),C.persist?J(se.current):ue.current=!0},[v,J,i]),p=o.useCallback(()=>{L.current!==null&&(Ie.current=!0)},[]),I=o.useCallback(()=>{var ee,Ee;const b=e.current,C=f.current;let N=C.width,z=C.height,q=N-24;if(b){const le=b.getBoundingClientRect();if(le.width>0&&le.height>0&&(N=le.width,z=le.height,q=N-24,Math.abs(f.current.width-N)>=1||Math.abs(f.current.height-z)>=1)){const je={width:Math.round(N),height:Math.round(z)};f.current=je,(ee=i.current)==null||ee.notifyViewportSize(je)}const Le=(Ee=b.closest(".bl-ch-workspace"))==null?void 0:Ee.querySelector(".bl-ch-drawer");if(Le){const je=Le.getBoundingClientRect();if(je.width>0){const Oe=le.width>0?le.left:0,ve=Oe+N;je.left<ve&&je.left>Oe+80&&(q=Math.min(q,je.left-Oe-24))}}}const X=24,E=24,fe=Math.max(E+80,z-64);return{vpW:N,vpH:z,safeLeft:X,safeRight:Math.max(X+120,q),safeTop:E,safeBottom:fe}},[i,e]),h=o.useCallback((b,C=!1)=>{const N=g.current.find(He=>He.id===b);if(!N)return!1;const{safeLeft:z,safeRight:q,safeTop:X,safeBottom:E}=I(),fe=R.current,ee=N.rect;if(C){const He=jn(fe.zoom),nt=(z+q)/2,Re=(X+E)/2;return F({x:nt-(ee.x+ee.width/2)*He,y:Re-(ee.y+ee.height/2)*He,zoom:He},{persist:!0,immediateRegion:!0}),!0}const Ee=Ye(fe.zoom),le=fe.x+ee.x*Ee,Le=fe.x+(ee.x+ee.width)*Ee,je=fe.y+ee.y*Ee,Oe=fe.y+(ee.y+ee.height)*Ee;let ve=0;Le>q?(ve=q-Le,le+ve<z&&(ve=z-le)):le<z&&(ve=z-le);let Me=0;return Oe>E?(Me=E-Oe,je+Me<X&&(Me=X-je)):je<X&&(Me=X-je),Math.abs(ve)<.5&&Math.abs(Me)<.5||F({x:fe.x+ve,y:fe.y+Me,zoom:Ee},{persist:!0,immediateRegion:!0}),!0},[I,F]);o.useLayoutEffect(()=>{const b=e.current;if(!b)return;const C=()=>{var E;B.current=null;const q=b.clientWidth,X=b.clientHeight;if(q>0&&X>0){const fe=f.current;if(fe.width!==q||fe.height!==X){const ee={width:q,height:X};f.current=ee,(E=i.current)==null||E.notifyViewportSize(ee),v(R.current,!1)}}};C();const N=()=>{B.current=null};window.addEventListener("resize",N,{passive:!0}),window.addEventListener("scroll",N,{passive:!0,capture:!0});let z=null;return typeof ResizeObserver<"u"&&(z=new ResizeObserver(C),z.observe(b)),()=>{window.removeEventListener("resize",N),window.removeEventListener("scroll",N,!0),z==null||z.disconnect()}},[v,i,e]),o.useLayoutEffect(()=>{B.current=null;const b=me.current,C=b!==T;if(C){if(me.current=T,b===null&&T!==null)_e.current={x:R.current.x,y:R.current.y,zoom:R.current.zoom},Ie.current=!1;else if(b!==null&&T===null){We.current=null;const N=_e.current,z=Ie.current;_e.current=null,Ie.current=!1,N&&!z&&F(N,{persist:!0,immediateRegion:!0});return}}if(We.current&&h(We.current,!0)){We.current=null;return}C&&T!==null&&h(T,!1)},[$,h,T,F]),o.useLayoutEffect(()=>{var q,X,E;const b=m!==Te.current,C=M!==re.current;if((b||C)&&(ge(),H(),ue.current=!1,_e.current=null,Ie.current=!1,me.current=T,se.current=`${m}:${M}`,Te.current=m,re.current=M,b&&(Z.current=x,we.current=l,l&&(R.current=l,v(l,!0),(q=i.current)==null||q.notifyCamera(l,{immediate:!0}))),C&&(Z.current=!1,we.current=null)),y&&!qt(y,R.current)){R.current=y,we.current=y,Z.current=!0,v(y,!0),(X=i.current)==null||X.notifyCamera(y,{immediate:!0});return}if(Z.current&&!C){v(R.current,!0);return}if($.length===0)return;const N=e.current;if(N&&N.clientWidth>0&&N.clientHeight>0){const fe={width:N.clientWidth,height:N.clientHeight};(fe.width!==f.current.width||fe.height!==f.current.height)&&(f.current=fe,(E=i.current)==null||E.notifyViewportSize(fe))}const z=xr($,V.current,f.current,{focusNodeId:ae.current});z&&F(z,{persist:!0,immediateRegion:!0})},[$,v,M,H,ge,y,l,x,m,i,F,e]),o.useEffect(()=>()=>{const b=se.current;if(Se.current!==0&&(window.clearTimeout(Se.current),Se.current=0),ue.current&&b===se.current){const C=R.current;qt(C,we.current)||(we.current={x:C.x,y:C.y,zoom:C.zoom},te.current(C,!0)),ue.current=!1}oe(),H()},[H,oe]);const S=o.useCallback(b=>{H(),p();const C=f.current,N=Qt(R.current,C.width/2,C.height/2);F(wt(R.current,b,N),{persist:!0,immediateRegion:!0})},[H,p,F]),O=o.useCallback(()=>{S(Ye(R.current.zoom+.2))},[S]),Q=o.useCallback(()=>{S(Ye(R.current.zoom-.2))},[S]),xe=o.useCallback(()=>{H(),p();const b=I(),C={width:b.vpW,height:b.vpH},N=L.current?{left:b.safeLeft,right:b.safeRight,top:b.safeTop,bottom:b.safeBottom}:void 0,z=gr(R.current,C,g.current,L.current,{safeArea:N,fallbackFocusNodeId:ae.current});F(z,{persist:!0,immediateRegion:!0})},[H,I,p,F]),$e=o.useCallback(()=>{H(),p();const b=[...g.current.map(N=>N.rect),...V.current],C=hr(b,f.current,At);C&&F(C,{persist:!0,immediateRegion:!0})},[H,p,F]),Fe=o.useCallback(()=>{H(),p();const b=L.current;if(!b)return;const C=g.current.find(X=>X.id===b);if(!C)return;const N=I(),z={width:N.vpW,height:N.vpH},q=fr([C.rect],z,{pad:At,safeArea:{left:N.safeLeft,right:N.safeRight,top:N.safeTop,bottom:N.safeBottom}});q&&F(q,{persist:!0,immediateRegion:!0})},[H,I,p,F]),Je=o.useCallback(()=>{H(),p();const b=g.current;if(b.length===0)return;const C=L.current,N=ae.current,z=(C?b.find(ee=>ee.id===C):void 0)??(N?b.find(ee=>ee.id===N):void 0)??b[b.length-1];if(!z)return;const q=I(),X={width:q.vpW,height:q.vpH},E=C?{left:q.safeLeft,right:q.safeRight,top:q.safeTop,bottom:q.safeBottom}:void 0,fe=jn(R.current.zoom);F(Wn(z.rect,X,fe,E),{persist:!0,immediateRegion:!0})},[H,I,p,F]),Qe=o.useCallback(b=>{H();const C=g.current.some(N=>N.id===b);if(L.current!==b||!C){We.current=b;return}h(b,!0)||(We.current=b)},[H,h]),rt=o.useCallback(b=>{H(),We.current=null,_e.current=L.current!==null?{x:b.x,y:b.y,zoom:b.zoom}:null,Ie.current=!1,F(b,{persist:!0,immediateRegion:!0})},[H,F]);o.useEffect(()=>{const b=e.current;if(!b)return;const C=z=>{_.current=0;const q=Pe.current;if(!q||document.hidden||he.current!==null){H();return}const X=Math.max(0,z-q.lastTime);q.lastTime=z;const E=ur(R.current,q.anim,X);F(E.camera,{persist:!1,immediateRegion:!1,zooming:!0}),E.done?(Pe.current=null,ne.current.zooming&&(ne.current.zooming=!1,pe()),J(se.current)):_.current=window.requestAnimationFrame(C)},N=z=>{var fe,ee;if(he.current!==null)return;if(z.ctrlKey||z.metaKey){z.preventDefault(),p();const Ee=cr(z,f.current.height);if(Ee===0)return;be.current!==null&&H(),ge();const le=((fe=Pe.current)==null?void 0:fe.anim.targetZoom)??R.current.zoom,Le=dr(le,Ee,"standard");if(Le===R.current.zoom){H();return}let je=B.current;if(!je){const He=b.getBoundingClientRect();je={left:He.left,top:He.top},B.current=je}const Oe=z.clientX-je.left,ve=z.clientY-je.top,Me=Qt(R.current,Oe,ve);if(Mr()){H(),F(wt(R.current,Le,Me),{persist:!0,immediateRegion:!1});return}ne.current.zooming||(ne.current.zooming=!0,pe()),Pe.current={anim:{targetZoom:Le,anchor:Me},lastTime:((ee=Pe.current)==null?void 0:ee.lastTime)??performance.now()},_.current===0&&(_.current=window.requestAnimationFrame(C));return}const q=z.target instanceof Element?z.target:null,X=q==null?void 0:q.closest('[data-card-scrollable="true"]');if(X instanceof HTMLElement&&X.scrollHeight>X.clientHeight){H();return}z.preventDefault();const E=lr(z,f.current);E.x===0&&E.y===0||(p(),Pe.current!==null&&H(),be.current||(be.current={x:0,y:0}),be.current.x+=E.x,be.current.y+=E.y,ne.current.wheelPanning||(ne.current.wheelPanning=!0,pe()),Ne.current===0&&(Ne.current=window.requestAnimationFrame(Ee=>{Ne.current=0;const le=be.current;if(be.current=null,!le||document.hidden||he.current!==null)return;const Le=Math.max(8,Math.min(64,Ee-(De.current||Ee-16)));De.current=Ee;const je=R.current,Oe={x:je.x-le.x,y:je.y-le.y,zoom:je.zoom};F(Oe,{persist:!1,immediateRegion:!1,vx:-le.x/Le,vy:-le.y/Le});const ve=se.current;Se.current!==0&&window.clearTimeout(Se.current),Se.current=window.setTimeout(()=>{Se.current=0,ne.current.wheelPanning&&(ne.current.wheelPanning=!1,pe()),ve===se.current&&ue.current&&J(ve)},Ir)})))};return b.addEventListener("wheel",N,{passive:!1}),()=>{b.removeEventListener("wheel",N),H()}},[H,ge,J,F,pe,e]);const tt=o.useCallback((b,C,N)=>{if(he.current!==null)return;H(),ge(),oe();const z={x:b.clientX,y:b.clientY},q=R.current.zoom,X=N?{x:N.originPosition.x,y:N.originPosition.y}:{x:R.current.x,y:R.current.y};let E={...X},fe={...X},ee=performance.now(),Ee=!1,le=0,Le=!1;const je=()=>{var Ke;le=0;const Re=performance.now(),Ge=Math.max(8,Math.min(64,Re-ee)),Ze=(E.x-fe.x)/Ge,Ue=(E.y-fe.y)/Ge;if(fe={...E},ee=Re,N){const ot=E.x-X.x,dt=E.y-X.y;C.style.transform=`translate(${ot}px, ${dt}px)`,(Ke=d.current)==null||Ke.call(d,N.nodeId,E)}else F({x:E.x,y:E.y,zoom:R.current.zoom},{persist:!1,immediateRegion:!1,vx:Ze,vy:Ue})},Oe=Re=>{var Ke;if(Re.pointerId!==b.pointerId)return;const Ge=Re.clientX-z.x,Ze=Re.clientY-z.y;if(!Ee&&Math.hypot(Ge,Ze)<Sr)return;if(!Ee){Ee=!0,K.current=!0,p();try{Re.type!=="pointerup"&&typeof C.setPointerCapture=="function"&&C.setPointerCapture(b.pointerId)}catch{}N?(ne.current.cardDragging=!0,C.setAttribute("data-dragging","true"),(Ke=i.current)==null||Ke.setPinnedCardId(N.nodeId),pe()):(ne.current.panning=!0,pe())}const Ue=N?q:1;E={x:X.x+Ge/Ue,y:X.y+Ze/Ue},le===0&&(le=window.requestAnimationFrame(je))},ve=(Re=!1)=>{var Ge,Ze,Ue;if(!Le){Le=!0,Re&&(K.current=!0),document.removeEventListener("pointermove",Oe),document.removeEventListener("pointerup",Me),document.removeEventListener("pointercancel",He),C.removeEventListener("lostpointercapture",nt),le!==0&&(window.cancelAnimationFrame(le),le=0);try{typeof C.hasPointerCapture=="function"&&C.hasPointerCapture(b.pointerId)&&C.releasePointerCapture(b.pointerId)}catch{}if(Ee){const Ke=Re?X:E;if(N){if(Re)C.style.transform="",C.setAttribute("data-dragging","false"),(Ge=d.current)==null||Ge.call(d,N.nodeId,X);else{const ot=Ke.x-X.x,dt=Ke.y-X.y;if(C.style.transform=`translate(${ot}px, ${dt}px)`,(Ze=d.current)==null||Ze.call(d,N.nodeId,Ke),Math.round(Ke.x)===Math.round(X.x)&&Math.round(Ke.y)===Math.round(X.y))C.style.transform="",C.setAttribute("data-dragging","false");else{const xt=window.setTimeout(()=>{oe()},60);ze.current={el:C,fallbackTimer:xt}}ce.current(N.nodeId,Ke)}(Ue=i.current)==null||Ue.setPinnedCardId(null)}else Re||p(),F({x:Ke.x,y:Ke.y,zoom:R.current.zoom},{persist:!0,immediateRegion:!1});window.setTimeout(()=>{K.current=!1},0)}he.current=null,ne.current.panning=!1,ne.current.cardDragging=!1,pe()}},Me=Re=>{Re.pointerId===b.pointerId&&(Oe(Re),ve(!1))},He=Re=>{Re.pointerId===b.pointerId&&ve(!1)},nt=Re=>{Re.pointerId===b.pointerId&&ve(!1)};he.current=ve,document.addEventListener("pointermove",Oe),document.addEventListener("pointerup",Me),document.addEventListener("pointercancel",He),C.addEventListener("lostpointercapture",nt)},[H,oe,ge,d,p,i,F,pe]);o.useEffect(()=>{const b=e.current;if(!b)return;const C=N=>{if(N.isPrimary===!1||N.button!==0&&N.button!==1)return;const z=N.target instanceof Element?N.target:null;if(!z||Wt(z)||z.closest('[data-testid="chronicle-canvas-controls"]'))return;const q=z.closest("[data-chronicle-node-id]"),X=z.closest("button, a, select, input, [data-card-action]");(N.button===1||N.button===0&&U.current||N.button===0&&!q&&!X)&&(N.preventDefault(),b.focus({preventScroll:!0}),tt(N,b,null))};return b.addEventListener("pointerdown",C),()=>{b.removeEventListener("pointerdown",C)}},[tt,e]);const lt=o.useCallback((b,C,N)=>{var q;if(b.isPrimary===!1||b.button!==0||U.current)return;const z=b.target instanceof Element?b.target:null;z!=null&&z.closest("[data-card-action], a, input, textarea, select")||((q=e.current)==null||q.focus({preventScroll:!0}),tt(b.nativeEvent,b.currentTarget,{nodeId:C,originPosition:N}))},[tt,e]);return o.useEffect(()=>{const b=()=>{Ce.current=!0},C=()=>{Ce.current=!1},N=E=>{if(E.isComposing||E.keyCode===229||Ce.current)return;if(E.key==="Escape"){if(he.current){E.preventDefault(),E.stopPropagation(),he.current(!0);return}if(Pe.current||be.current){E.preventDefault(),H();return}if(U.current){U.current=!1,pe();return}return}if(Wt(document.activeElement)||Wt(E.target)||document.querySelector('[role="dialog"][aria-modal="true"]')!==null)return;const fe=e.current,ee=document.activeElement;if(fe!==null&&ee instanceof Element&&(fe.contains(ee)||ee.closest('[data-testid="chronicle-canvas-controls"]')!==null)){if(E.key===" "){if(ee instanceof Element&&ee.closest('button, [role="button"]')&&!ee.hasAttribute("data-chronicle-node-id"))return;!E.ctrlKey&&!E.metaKey&&!E.altKey&&(E.preventDefault(),U.current||(U.current=!0,pe()));return}if(!(E.ctrlKey||E.metaKey||E.altKey)){if(E.shiftKey&&(E.code==="Digit1"||E.key==="!")){E.preventDefault(),$e();return}if(E.shiftKey&&(E.code==="Digit2"||E.key==="@")){E.preventDefault(),Fe();return}if(E.key==="0"&&!E.shiftKey){E.preventDefault(),xe();return}if((E.key==="f"||E.key==="F")&&!E.shiftKey){E.preventDefault(),Je();return}if(E.key==="+"||E.key==="="){E.preventDefault(),O();return}(E.key==="-"||E.key==="_")&&(E.preventDefault(),Q())}}},z=E=>{E.key===" "&&U.current&&(U.current=!1,pe())},q=()=>{var E;U.current&&(U.current=!1,pe()),(E=he.current)==null||E.call(he,!1),H()},X=()=>{var E;document.hidden&&(U.current&&(U.current=!1,pe()),(E=he.current)==null||E.call(he,!0),H())};return document.addEventListener("compositionstart",b,!0),document.addEventListener("compositionend",C,!0),document.addEventListener("keydown",N,!0),document.addEventListener("keyup",z),window.addEventListener("blur",q),document.addEventListener("visibilitychange",X),()=>{var E;document.removeEventListener("compositionstart",b,!0),document.removeEventListener("compositionend",C,!0),document.removeEventListener("keydown",N,!0),document.removeEventListener("keyup",z),window.removeEventListener("blur",q),document.removeEventListener("visibilitychange",X),(E=he.current)==null||E.call(he,!0),H()}},[H,Je,$e,Fe,xe,pe,e,O,Q]),{cameraRef:R,viewportSizeRef:f,suppressClickRef:K,initialZoomPct:Math.round(G.zoom*100),syncCameraToDom:W,clearPendingDragTransform:oe,zoomIn:O,zoomOut:Q,resetZoom100:xe,fitAll:$e,fitSelected:Fe,centerCurrent:Je,setZoomAtCenter:S,focusNodeInView:Qe,restoreCamera:rt,beginCardPointerDown:lt}}const Pr=[{label:"平移画布",keys:"滚轮 / 拖空白区 / Space+拖"},{label:"缩放画布",keys:"⌘/Ctrl+滚轮 · + / − · 0(100%)"},{label:"适配视角",keys:"Shift+1 全部 · Shift+2 选中 · F 居中"},{label:"快速搜索定位",keys:"/ 搜索 · Enter 定位 · Esc 复原"},{label:"快捷键帮助",keys:"? 打开 / 切换 · Esc 关闭"},{label:"关闭与取消",keys:"Esc 关抽屉 / 取消拖卡"}];function En(e){return e instanceof Element?e.closest("input, textarea, select")!==null||e.closest('[contenteditable]:not([contenteditable="false"])')!==null:!1}const Mn=new Set,Tr={},Lr=(e,s)=>{},Ar=(e,s)=>{},_r=e=>{},$r=e=>{},Br=e=>{},Zn=ct.memo(()=>{const[e,s]=o.useState(!1),n=o.useRef(null),r=o.useRef(null),a=o.useRef(null),u=o.useCallback(()=>{var m;const d=a.current;if(a.current=null,d&&d!==document.body&&d.isConnected){d.focus({preventScroll:!0});return}(m=r.current)==null||m.focus({preventScroll:!0})},[]);o.useEffect(()=>{const d=m=>{var x;m.isComposing||m.keyCode===229||m.ctrlKey||m.metaKey||m.altKey||!(m.key==="?"||m.shiftKey&&(m.code==="Slash"||m.key==="/"))||En(document.activeElement)||En(m.target)||document.querySelector('[role="dialog"][aria-modal="true"]')===null&&(m.target instanceof Element&&m.target.closest('[role="dialog"]')!==null&&!((x=n.current)!=null&&x.contains(m.target))||(m.preventDefault(),s(y=>y?(window.setTimeout(()=>u(),0),!1):(a.current=document.activeElement instanceof HTMLElement?document.activeElement:null,!0))))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[u]),o.useEffect(()=>{if(!e)return;const d=l=>{n.current&&l.target instanceof Node&&!n.current.contains(l.target)&&(s(!1),a.current=null)},m=l=>{if(l.key==="Escape"){if(document.querySelector('[role="dialog"][aria-modal="true"]')!==null)return;l.preventDefault(),l.stopPropagation(),s(!1),u()}};return document.addEventListener("pointerdown",d,!0),document.addEventListener("keydown",m,!0),()=>{document.removeEventListener("pointerdown",d,!0),document.removeEventListener("keydown",m,!0)}},[e,u]);const i=()=>{s(d=>d?!1:(a.current=r.current,!0))};return t.jsxs("div",{ref:n,className:"relative inline-flex items-center",children:[t.jsx("button",{ref:r,type:"button",onClick:i,"aria-expanded":e,"aria-label":"画布快捷键帮助",title:"画布快捷键帮助 (?)","data-testid":"chronicle-shortcuts-btn","data-active":e?"true":"false",className:"bl-ch-zoom-btn bl-ch-shortcuts-btn mono",children:"?"}),e&&t.jsxs("div",{role:"dialog","aria-label":"画布快捷键列表","data-testid":"chronicle-shortcuts-popover",className:"bl-ch-shortcuts-popover",children:[t.jsx("div",{className:"bl-ch-shortcuts-title",children:"画布快捷键"}),t.jsx("dl",{className:"bl-ch-shortcuts-list",children:Pr.map(d=>t.jsxs("div",{className:"bl-ch-shortcuts-row",children:[t.jsx("dt",{children:d.label}),t.jsx("dd",{className:"mono",children:d.keys})]},d.label))})]})]})});Zn.displayName="ShortcutsHelpButton";const Qn=ct.memo(({repoKey:e,baseBranch:s,phases:n,nodes:r,edges:a,filters:u,selectedNodeId:i,focusedNodeId:d=null,trunkCollapseEnabled:m=!1,expandedTrunkSegmentIds:l=Mn,collapsedBranchIds:x=Mn,lockedPositions:y=Tr,trunkFold:M,savedCamera:$,cameraInitialized:k,arrangeSeq:w=0,canvasHandleRef:T,searchMatchIds:j,activeDshSessionId:D=null,showPhaseSummary:A=!0,onSelectNode:G,onFocusNode:R,onToggleCollapseBranch:f,onExpandTrunkSegment:B,onPersistCamera:g=Lr,onCommitCardDrag:V=Ar})=>{var ge;const ae=o.useRef(null),L=o.useRef(null),ie=o.useRef(null),te=o.useRef(null),ce=o.useRef(null),U=o.useRef(null),Ce=o.useRef(null),K=o.useRef(null),Y=o.useRef(null),se=o.useRef(null),Te=o.useMemo(()=>{if($!==void 0||k!==void 0)return{camera:$??null,initialized:!!k};if(!e)return{camera:null,initialized:!1};const J=ye.getState().byRepo[e];return{camera:(J==null?void 0:J.camera)??null,initialized:!!(J!=null&&J.cameraInitialized)}},[e,$,k]),re=o.useMemo(()=>As(n,r,a,s,{filters:u,focusedNodeId:d,trunkCollapseEnabled:m,expandedTrunkSegmentIds:l,collapsedBranchIds:x,lockedPositions:y,trunkFold:M,showPhaseSummary:A}),[n,r,a,s,u,d,m,l,x,y,M,A]),Z=o.useMemo(()=>re.nodes.map(J=>({id:J.id,rect:{x:J.x,y:J.y,width:Xe,height:Ae}})),[re.nodes]),ue=o.useMemo(()=>{const J=re.collapsedSegments.map(H=>({x:H.x-72,y:H.y-20,width:144,height:40}));if(re.nodes.length>0){let H=re.phaseHeaderHeight+20+Ae;for(const F of re.nodes)H=Math.max(H,F.y+Ae);J.push({x:0,y:0,width:it,height:H})}return J},[re.collapsedSegments,re.nodes,re.phaseHeaderHeight]),we=o.useMemo(()=>{if(re.nodes.length===0)return null;const J=p=>{let I=p[p.length-1],h=Date.parse(I.node.timestamp);Number.isNaN(h)&&(h=-1/0);for(const S of p){const O=Date.parse(S.node.timestamp),Q=Number.isNaN(O)?-1/0:O;(Q>h||Q===h&&S.x>=I.x)&&(I=S,h=Q)}return I};if(D){const p=re.nodes.filter(I=>{var h;return((h=I.node.requirementMeta)==null?void 0:h.sessionId)===D});if(p.length>0)return J(p).id}const H=re.nodes.filter(p=>p.node.status==="working");if(H.length>0)return J(H).id;const F=re.nodes.filter(p=>p.node.status==="active");return F.length>0?J(F).id:J(re.nodes).id},[re.nodes,D]),{cameraRef:ke,viewportSizeRef:_,suppressClickRef:Pe,initialZoomPct:Ne,syncCameraToDom:be,clearPendingDragTransform:De,zoomIn:Se,zoomOut:he,resetZoom100:_e,fitAll:Ie,fitSelected:me,centerCurrent:We,focusNodeInView:ne,restoreCamera:ze,beginCardPointerDown:pe}=Rr({viewportRef:L,stageRef:ie,svgWorldGroupRef:te,stickyRailRef:ce,zoomPctTextRef:U,zoomPctBtnRef:Ce,schedulerRef:K,edgeDragUpdaterRef:Y,repoKey:e,initialCamera:Te.camera,initialCameraInitialized:Te.initialized,externalCamera:$!==void 0?$:void 0,arrangeSeq:w,allCardRects:Z,fitExtraRects:ue,recentFocusNodeId:we,selectedNodeId:i,phaseHeaderHeight:re.phaseHeaderHeight,onPersistCamera:g,onCommitCardDrag:V}),v=o.useMemo(()=>_s(i,re.edges.map(J=>J.edge),re.adjacency),[i,re.edges,re.adjacency]),W=o.useCallback(J=>{se.current=J},[]),oe=o.useCallback(J=>{var H;(H=se.current)==null||H.call(se,J)},[]);return o.useImperativeHandle(T,()=>({getCamera:()=>({x:ke.current.x,y:ke.current.y,zoom:ke.current.zoom}),restoreCamera:ze,focusNodeInView:ne}),[ke,ne,ze]),re.nodes.length===0?t.jsx("div",{className:"bl-ch-canvas-wrap flex items-center justify-center p-10 text-center","data-testid":"chronicle-swimlane-view",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-[14px] font-medium",children:"当前视图范围内暂无可展示的节点"}),t.jsx("div",{className:"text-[12px]",style:{color:"var(--muted)"},children:"尝试调整筛选条件或退出当前聚焦范围。"})]})}):t.jsx("div",{ref:ae,className:"bl-ch-canvas-wrap","data-testid":"chronicle-swimlane-view","data-overview":"false",children:t.jsxs("div",{ref:L,tabIndex:0,role:"region","aria-label":"软件开发历程交互式画布","data-testid":"chronicle-canvas-viewport","data-panning":"false","data-space-pan":"false","data-dragging-card":"false","data-zoom":(((ge=Te.camera)==null?void 0:ge.zoom)??1).toFixed(3),"data-overview":"false","data-trunk-columns":re.keptTrunkColumns,className:"bl-ch-canvas-viewport",children:[t.jsx(Vn,{layout:re,showPhaseSummary:A,selectedNodeId:i,latestNodeId:we,focusedNodeId:d,collapsedBranchIds:x,searchMatchIds:j,lineageNodeIds:v.nodeIds,lineageEdgeIds:v.edgeIds,wrapRef:ae,viewportRef:L,stageRef:ie,svgWorldGroupRef:te,stickyRailRef:ce,cameraRef:ke,viewportSizeRef:_,suppressClickRef:Pe,schedulerRef:K,edgeDragUpdaterRef:Y,onRegionBadgeChange:oe,onSyncCameraToDom:be,onLayoutCommitted:De,hasToggleCollapseBranch:!!f,hasFocusNode:!!R,onBeginCardPointerDown:pe,onSelectNode:G,onFocusNode:R??_r,onToggleCollapseBranch:f??$r,onExpandTrunkSegment:B??Br}),t.jsxs("div",{className:"bl-ch-canvas-bar","data-testid":"chronicle-canvas-controls",children:[t.jsxs("div",{className:"bl-ch-legend",children:[t.jsxs("span",{className:"bl-ch-legend-item",children:[t.jsx("span",{className:"bl-ch-legend-line bl-ch-legend-trunk"}),"主干演进"]}),t.jsxs("span",{className:"bl-ch-legend-item",children:[t.jsx("span",{className:"bl-ch-legend-line bl-ch-legend-fork"}),"分支分叉"]}),t.jsxs("span",{className:"bl-ch-legend-item",children:[t.jsx("span",{className:"bl-ch-legend-line bl-ch-legend-merge"}),"合入回流"]}),t.jsxs("span",{className:"bl-ch-legend-item",children:[t.jsx("span",{className:"bl-ch-legend-line bl-ch-legend-span"}),"筛选跨越"]}),t.jsx(Yn,{registerBadgeUpdater:W})]}),t.jsxs("div",{className:"bl-ch-zoom-controls",role:"toolbar","aria-label":"画布缩放与视图控制",children:[t.jsx("button",{type:"button",onClick:he,"data-testid":"chronicle-zoom-out","aria-label":"缩小画布",title:"缩小 (-)",className:"bl-ch-zoom-btn mono",children:"−"}),t.jsx("button",{ref:Ce,type:"button",onClick:_e,"data-testid":"chronicle-zoom-pct","aria-label":`当前缩放 ${Ne}%,点击恢复 100%`,title:"恢复 100% (0)",className:"bl-ch-zoom-btn bl-ch-zoom-pct mono",children:t.jsx("span",{ref:U,children:`${Ne}%`})}),t.jsx("button",{type:"button",onClick:Se,"data-testid":"chronicle-zoom-in","aria-label":"放大画布",title:"放大 (+)",className:"bl-ch-zoom-btn mono",children:"+"}),t.jsx("span",{className:"bl-ch-zoom-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:Ie,"data-testid":"chronicle-fit-all",title:"适配全部节点 (Shift+1)",className:"bl-ch-zoom-btn",children:"适配全部"}),t.jsx("button",{type:"button",onClick:me,disabled:!i,"data-testid":"chronicle-fit-selected",title:"适配选中节点 (Shift+2)",className:"bl-ch-zoom-btn disabled:opacity-40",children:"适配选中"}),t.jsx("button",{type:"button",onClick:We,"data-testid":"chronicle-center-current",title:"居中当前节点 (F)",className:"bl-ch-zoom-btn",children:"定位当前"}),t.jsx("span",{className:"bl-ch-zoom-sep","aria-hidden":"true"}),t.jsx(Zn,{})]})]})]})})});Qn.displayName="ChronicleSwimlaneGraph";const Or=({phases:e,nodes:s,selectedNodeId:n,showPhaseSummary:r=!0,onSelectNode:a})=>{const u=[...e].sort((l,x)=>l.order-x.order),i=new Set(u.map(l=>l.id)),d=[];for(const l of u){const x=s.filter(y=>y.phaseId===l.id).sort((y,M)=>Date.parse(y.timestamp)-Date.parse(M.timestamp));x.length>0&&d.push({phase:l,items:x})}const m=s.filter(l=>!i.has(l.phaseId));return m.length>0&&d.push({phase:{id:"__other__",order:u.length+1,title:"其他演进记录",goal:"未归入阶段的提交与任务",summary:"",nodeIds:m.map(l=>l.id)},items:m}),t.jsx("div",{className:"bl-ch-timeline-wrap","data-testid":"chronicle-timeline-view",children:t.jsx("div",{className:"bl-ch-timeline-inner",children:d.map(({phase:l,items:x},y)=>{var $;const M=l.startAt&&l.endAt?`${Rt(l.startAt)} — ${Rt(l.endAt)}`:Rt(l.startAt||l.endAt);return t.jsxs("section",{className:"bl-ch-tl-phase","data-timeline-phase":l.id,children:[t.jsxs("header",{className:"bl-ch-tl-phase-head",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[t.jsxs("div",{className:"flex items-baseline gap-2.5 min-w-0",children:[t.jsxs("span",{className:"bl-ch-phase-ord mono",children:["STAGE ",String(l.order||y+1).padStart(2,"0")]}),t.jsx("h2",{className:"text-[17px] font-semibold tracking-tight",children:l.title})]}),t.jsxs("div",{className:"flex items-center gap-2 text-[11px] mono",style:{color:"var(--faint)"},children:[M&&t.jsx("span",{children:M}),t.jsxs("span",{children:[x.length," 个迭代节点"]})]})]}),l.goal&&t.jsxs("p",{className:"text-[12.5px] font-medium mt-1.5",style:{color:"var(--ink)"},children:["阶段目标:",l.goal]}),r&&(($=l.summary)==null?void 0:$.trim())&&t.jsxs("p",{className:"bl-ch-tl-phase-summary mt-1.5","data-testid":"chronicle-phase-summary",children:[t.jsx("span",{className:"bl-ch-phase-summary-spark","aria-hidden":"true",children:"✦"}),t.jsx("span",{children:l.summary.trim()})]})]}),t.jsx("ol",{className:"bl-ch-tl-list",children:x.map(k=>{var ae,L,ie,te;const w=n===k.id,T=en(k.origin),j=Ut[k.status],D=Jt[k.impactCategory],A=yt(k),G=k.branchMeta,R=k.requirementMeta,f=A&&!!R&&k.origin.conversationSource!=="git-inferred",B=((ae=k.subtitle)==null?void 0:ae.trim())||"",g=((L=R==null?void 0:R.userPrompt)==null?void 0:L.trim())||((ie=k.requirementOrigin)==null?void 0:ie.trim())||k.title,V=!!(k.rawTitle&&k.rawTitle.trim()&&k.rawTitle.trim()!==k.title.trim());return t.jsxs("li",{className:"bl-ch-tl-item",children:[t.jsx("span",{className:"bl-ch-tl-dot","data-status":k.status,"data-selected":w?"true":"false","aria-hidden":"true"}),t.jsxs("article",{className:"bl-ch-tl-card","data-selected":w?"true":"false","data-timeline-node-id":k.id,children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 min-w-0",children:[R&&t.jsxs("span",{className:"bl-ch-turn-badge mono",children:["#",R.turnIndex]}),t.jsx("span",{className:"bl-ch-badge","data-tone":T,children:tn(k.origin)}),k.origin.stale&&t.jsx("span",{className:"bl-ch-badge","data-tone":"stale","data-stale-badge":"true",children:"旧提交"}),t.jsx("span",{className:"bl-ch-status","data-tone":j.tone,children:j.label}),t.jsx("span",{className:"bl-ch-impact","data-impact":D.tone,children:D.label})]}),t.jsx("span",{className:"mono text-[11px]",style:{color:"var(--faint)"},children:Tt(k.timestamp)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-baseline justify-between gap-2",children:[t.jsx("h3",{className:"text-[14.5px] font-semibold leading-snug",title:f?g:V?`原始标题:${k.rawTitle}`:k.title,children:k.title}),t.jsxs("span",{className:"mono text-[11px]",style:{color:"var(--faint)"},title:V?`原始标题:${k.rawTitle}`:void 0,children:[k.ref," · ",k.shortSha||"无提交坐标",G&&G.commitCount>0?` · ${G.commitCount} 次提交`:R&&R.linkedCommitCount>0?` · 关联 ${R.linkedCommitCount} 提交`:""]})]}),B&&t.jsxs("p",{className:"bl-ch-tl-subtitle mt-1","data-testid":"chronicle-timeline-subtitle",title:B,children:[t.jsx("span",{className:"bl-ch-subtitle-prefix",children:"做了 · "}),t.jsx("span",{children:B})]}),A&&!f&&t.jsxs("div",{className:"bl-ch-tl-origin mt-2",children:[t.jsx("span",{className:"bl-ch-origin-prefix",children:"需求由来"}),t.jsx("span",{children:((te=R==null?void 0:R.userPrompt)==null?void 0:te.trim())||k.requirementOrigin})]}),t.jsx("p",{className:"text-[12.5px] leading-relaxed mt-2",style:{color:"var(--ink)"},children:k.summary}),k.improvements.length>0&&t.jsx("ul",{className:"bl-ch-tl-bullets mt-2",children:k.improvements.slice(0,4).map((ce,U)=>t.jsx("li",{children:ce},U))}),t.jsxs("div",{className:"mt-3 pt-2 flex flex-wrap items-center justify-between gap-2",style:{borderTop:"1px solid var(--hair)"},children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-[11px] mono",style:{color:"var(--faint)"},children:[t.jsxs("span",{children:["变动 ",k.evidence.changedFilesCount," 个文件"]}),(G==null?void 0:G.absorbedTrunkCommits)&&G.absorbedTrunkCommits>0&&t.jsxs("span",{children:["含 ",G.absorbedTrunkCommits," 历史提交"]}),k.mergedIntoRef&&t.jsxs("span",{children:["合入 → ",k.mergedIntoRef]})]}),t.jsx("button",{type:"button",onClick:()=>a(k.id),className:"sheet-link text-[12px]",children:"查看溯源详情 →"})]})]})]},k.id)})})]},l.id)})})})},Dr=ct.lazy(()=>fs(()=>import("./ExecutionTraceView-BuKMTJLz.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(e=>({default:e.ExecutionTraceView}))),zr={},Rn=[];function Pn(e){return e instanceof Element?e.closest("input, textarea, select")!==null||e.closest('[contenteditable]:not([contenteditable="false"])')!==null:!1}function Fr(e,s){var r,a;return[e.title,e.subtitle,e.rawTitle,e.ref,e.shortSha,e.sha,e.requirementOrigin,(r=e.requirementMeta)==null?void 0:r.userPrompt,(a=e.requirementMeta)==null?void 0:a.sessionTitle,e.summary].some(u=>typeof u=="string"&&u.toLowerCase().includes(s))}const Hr=[{value:"all",label:"全部来源"},{value:"agent",label:"开发 Agent"},{value:"task",label:"BranchLens 任务"},{value:"ai-git",label:"AI · Git"}],Kr=[{value:"all",label:"全部状态"},{value:"merged",label:"已合入 / 采纳"},{value:"active",label:"进行中"},{value:"trunk",label:"主干"},{value:"working",label:"未提交"},{value:"archived",label:"已归档"}],Wr=[{value:"all",label:"全部类型"},{value:"frontend",label:"前端"},{value:"backend",label:"后端"},{value:"fullstack",label:"全栈"},{value:"config",label:"配置"},{value:"docs",label:"文档"}],qr=[{id:"branch",label:"按分支",title:"按分支与主干里程碑聚合(推荐默认,结构精炼清晰)"},{id:"requirement",label:"按对话需求",title:"聚合 DSH / Codex / BranchLens / 外部 Agent 对话轮次与 Git 归纳"},{id:"commit",label:"完整提交",title:"展示完整主干与分支提交拓扑(支持主干精简折叠)"}],Qr=()=>{const e=Xt(c=>c.repo),s=Xt(c=>c.dshContext),n=st(c=>c.granularity),r=st(c=>c.setGranularity),a=cs(e),u=(s==null?void 0:s.sessionId)||(e==null?void 0:e.activeDshSessionId)||null,i=st(c=>c.chronicle),d=st(c=>c.loading),m=st(c=>c.submitting),l=st(c=>c.error),x=st(c=>c.staleVersion),y=st(c=>c.loadChronicle),M=st(c=>c.submitChronicle),$=st(c=>c.clearChronicle),{isHarnessPanel:k}=ls(),w=(e==null?void 0:e.repoHash)||(i==null?void 0:i.repoPath)||"__default__",T=St(w,n),j=k?"timeline":"swimlane",D=!!(e&&i&&i.repoPath!==e.repoPath),A=!!(i&&i.granularity&&i.granularity!==n),G=e&&i&&!D&&A?ds(e.repoPath,n):null,R=!!(i&&!D&&A&&!G),f=!i||D?null:A?G??i:i,B=R?(i==null?void 0:i.granularity)??n:n,g=St(w,B),V=ye(c=>c.ensureRepo),ae=ye(c=>!!c.byRepo[w]),L=ye(c=>{var P;return((P=c.byRepo[w])==null?void 0:P.viewMode)??j}),ie=ye(c=>{var P;return((P=c.byRepo[w])==null?void 0:P.userPickedView)??!1}),te=ye(c=>{var P;return((P=c.byRepo[g])==null?void 0:P.filters)??Mt}),ce=ye(c=>{var P;return((P=c.byRepo[g])==null?void 0:P.selectedNodeId)??null}),U=ye(c=>{var P;return((P=c.byRepo[g])==null?void 0:P.focusedNodeId)??null}),Ce=ye(c=>{var P;return((P=c.byRepo[g])==null?void 0:P.trunkCollapseEnabled)??!0}),K=ye(c=>{var P;return((P=c.byRepo[g])==null?void 0:P.expandedTrunkSegmentIds)??Rn}),Y=ye(c=>{var P;return((P=c.byRepo[g])==null?void 0:P.collapsedBranchIds)??Rn}),se=ye(c=>{var P;return((P=c.byRepo[g])==null?void 0:P.arrangeSeq)??0}),Te=ye(c=>c.lockedPositionsByRepo[g]??zr),re=ye(c=>c.setViewMode),Z=ye(c=>c.setFilters),ue=ye(c=>c.setSelectedNodeId),we=ye(c=>c.setFocusedNodeId),ke=ye(c=>c.setTrunkCollapseEnabled),_=ye(c=>c.toggleExpandTrunkSegment),Pe=ye(c=>c.toggleCollapseBranch),Ne=ye(c=>c.setCamera),be=ye(c=>c.setLockedPosition),De=ye(c=>c.autoArrange),Se=ye(c=>c.showPhaseSummary),he=ye(c=>c.toggleShowPhaseSummary),[_e,Ie]=o.useState(!1),[me,We]=o.useState("idle"),[ne,ze]=o.useState(!1),[pe,v]=o.useState(!1),[W,oe]=o.useState(""),[ge,J]=o.useState(0),[H,F]=o.useState(null),[p,I]=o.useState(null);o.useEffect(()=>{a&&n!=="requirement"&&r("requirement",{persist:!1})},[a,n,r]),o.useEffect(()=>{L==="trace"&&w&&I(c=>c===w?c:w)},[L,w]);const h=o.useRef(null),S=o.useRef(null),O=o.useRef(null),Q=o.useRef(null),xe=o.useRef(!1),$e=o.useRef(null),Fe=o.useRef(null),Je=o.useRef(null),Qe=o.useRef(null),rt=o.useRef(!0);o.useEffect(()=>(rt.current=!0,()=>{var c;rt.current=!1,(c=Je.current)==null||c.abort(),Je.current=null,Fe.current!==null&&(window.clearTimeout(Fe.current),Fe.current=null)}),[]),o.useEffect(()=>{!i||D||A||i.repoPath&&us(i.repoPath,i.granularity??n,i)},[i,D,A,n]),o.useEffect(()=>{var de,Ve,Be;const c=e==null?void 0:e.repoPath;if(!c)return;const P=$e.current;if(P&&P.repoPath!==c){(de=Je.current)==null||de.abort(),Je.current=null,Qe.current=null,I(null),Ie(!1),v(!1),F(null);for(const qe of["branch","requirement","commit"]){const et=St(P.repoKey,qe),ft=St(w,qe);(Ve=ye.getState().byRepo[et])!=null&&Ve.selectedNodeId&&ue(et,null),(Be=ye.getState().byRepo[ft])!=null&&Be.selectedNodeId&&ue(ft,null)}}$e.current={repoPath:c,repoKey:w}},[e==null?void 0:e.repoPath,w,ue]),o.useEffect(()=>{e!=null&&e.repoPath&&x>0&&vt(e.repoPath,n)},[e==null?void 0:e.repoPath,n,x]),o.useEffect(()=>{v(!1),oe(""),J(0),Q.current=null,xe.current=!1},[T]),o.useEffect(()=>{if(!pe)return;const c=de=>{O.current&&de.target instanceof Node&&!O.current.contains(de.target)&&v(!1)},P=de=>{de.key==="Escape"&&(de.preventDefault(),de.stopPropagation(),v(!1))};return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",P,!0),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",P,!0)}},[pe]),o.useEffect(()=>{const c=P=>{if(P.isComposing||P.keyCode===229||P.ctrlKey||P.metaKey||P.altKey||P.shiftKey||P.key!=="/"||Pn(document.activeElement)||Pn(P.target)||document.querySelector('[role="dialog"][aria-modal="true"]')!==null)return;const de=S.current;de&&(P.preventDefault(),de.focus(),de.select())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[]),o.useEffect(()=>{V(w,j),V(T,j)},[V,w,T,j]),o.useEffect(()=>{k&&ae&&!ie&&L!=="timeline"&&re(w,"timeline",!1)},[ae,k,w,re,ie,L]);const tt=o.useMemo(()=>new Set(K),[K]),lt=o.useMemo(()=>new Set(Y),[Y]);o.useEffect(()=>{e&&!d&&(!i&&!l||D||A||x>0)&&y(!1,n)},[e,i,D,A,l,x,d,y,n]),o.useEffect(()=>{!i||D||A||(ce&&!i.nodes.some(c=>c.id===ce)&&ue(T,null),U&&!i.nodes.some(c=>c.id===U)&&we(T,null))},[i,D,A,U,T,ce,we,ue]),o.useEffect(()=>{if(!ce)return;const c=P=>{P.key==="Escape"&&(P.defaultPrevented||document.querySelector('[role="dialog"][aria-modal="true"]')!==null||ue(T,null))};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[T,ce,ue]);const b=o.useMemo(()=>f?$n(f.nodes,te):[],[f,te]),C=W.trim().toLowerCase(),N=o.useMemo(()=>C?b.filter(c=>Fr(c,C)):[],[b,C]),z=o.useMemo(()=>{if(!(!C||N.length===0))return new Set(N.map(c=>c.id))},[C,N]),q=N.length>0?Math.min(ge,N.length-1):0,X=B==="commit"&&Ce,E=o.useMemo(()=>f?f.nodes.filter(c=>c.status==="trunk").length:0,[f]),fe=B==="commit"&&E>=120,ee=o.useMemo(()=>f?Ln(f.nodes,f.edges,{enabled:X,expandedSegmentIds:tt}):void 0,[f,tt,X]),Ee=o.useCallback(c=>{var Ve;if(!f||N.length===0)return;const P=(c%N.length+N.length)%N.length;J(P),xe.current=!0;const de=N[P];if(!Q.current&&h.current){const Be=h.current.getCamera();Q.current={x:Be.x,y:Be.y,zoom:Be.zoom}}if(X&&ee)for(const Be of ee.segments)Be.nodes.some(qe=>qe.id===de.id)&&!tt.has(Be.id)&&_(T,Be.id);if(lt.size>0){const Be=xs(f.nodes,f.edges,de.id,lt);for(const qe of lt)Be.has(qe)||Pe(T,qe)}if(U){const Be=Tn(f.nodes,f.edges,U);Be&&!Be.has(de.id)&&we(T,null)}ue(T,de.id),(Ve=h.current)==null||Ve.focusNodeInView(de.id)},[T,f,lt,X,tt,U,N,we,ue,ee,Pe,_]),le=o.useCallback(()=>{var P;const c=Q.current;Q.current=null,xe.current=!1,oe(""),J(0),c&&((P=h.current)==null||P.restoreCamera(c))},[]),Le=c=>{oe(c.target.value),J(0),xe.current=!1},je=c=>{var P;if(!(c.nativeEvent.isComposing||c.keyCode===229)){if(c.key==="Enter"){if(c.preventDefault(),N.length===0)return;const de=xe.current?c.shiftKey?q-1:q+1:q;Ee(de);return}c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),le(),(P=S.current)==null||P.blur())}},Oe=o.useMemo(()=>({hiddenCount:(ee==null?void 0:ee.hiddenTrunkIds.size)??0,segmentCount:(ee==null?void 0:ee.segments.length)??0}),[ee]),ve=o.useMemo(()=>!!(f!=null&&f.nodes.some(c=>c.origin.stale)),[f]),Me=o.useMemo(()=>(f==null?void 0:f.nodes.find(c=>c.id===ce))??null,[f,ce]),He=o.useMemo(()=>(f==null?void 0:f.nodes.find(c=>c.id===U))??null,[f,U]),nt=o.useMemo(()=>!Me||!f?!1:f.edges.some(c=>c.kind==="fork"&&c.fromId===Me.id),[f,Me]),Re=o.useMemo(()=>Me&&f?f.phases.find(c=>c.id===Me.phaseId):void 0,[f,Me]),Ge=o.useCallback((c,P=!0)=>{Ne(g,c,P)},[g,Ne]),Ze=o.useCallback((c,P)=>{be(g,c,P)},[g,be]),Ue=o.useCallback(c=>{var de;const P=((de=ye.getState().byRepo[g])==null?void 0:de.selectedNodeId)??null;ue(g,P===c?null:c)},[g,ue]),Ke=o.useCallback(c=>{we(g,c)},[g,we]),ot=o.useCallback(c=>{Pe(g,c)},[g,Pe]),dt=o.useCallback(c=>{_(g,c)},[g,_]),kt=o.useCallback(()=>{ue(g,null)},[g,ue]),xt=o.useCallback(c=>{ue(g,c)},[g,ue]),Un=o.useCallback(()=>{re(w,"swimlane",!0)},[w,re]),Jn=o.useMemo(()=>H??(u?{source:"dsh",sessionId:u}:null),[H,u]),Ot=o.useCallback(c=>{We(c),Fe.current!==null&&window.clearTimeout(Fe.current),Fe.current=window.setTimeout(()=>{Fe.current=null,rt.current&&We("idle")},2200)},[]),nn=o.useCallback(async()=>{var Ve,Be;if(!f)return{markdown:null};if(f.fullMarkdown)return{markdown:f.fullMarkdown};const c=f.granularity??B,P=`${f.repoPath}::${c}::${f.fingerprint}::${f.generatedAt}`;if(((Ve=Qe.current)==null?void 0:Ve.key)===P&&Qe.current.markdown)return{markdown:Qe.current.markdown};(Be=Je.current)==null||Be.abort();const de=new AbortController;Je.current=de,ze(!0);try{const qe=await un.getProjectChronicleMarkdown(c,de.signal),et=typeof(qe==null?void 0:qe.markdown)=="string"?qe.markdown:"";return et?(Qe.current={key:P,markdown:et},{markdown:et}):{markdown:null}}catch(qe){if(hn(qe))return{markdown:null,aborted:!0};if(qe instanceof hs&&qe.status===404)try{const et=await un.getProjectChronicle(!1,c,{includeMarkdown:!0,signal:de.signal}),ft=typeof(et==null?void 0:et.fullMarkdown)=="string"?et.fullMarkdown:"";if(ft)return Qe.current={key:P,markdown:ft},{markdown:ft}}catch(et){if(hn(et))return{markdown:null,aborted:!0}}return{markdown:null}}finally{Je.current===de&&(Je.current=null),rt.current&&ze(!1)}},[f,B]),es=async()=>{if(!f)return;let c=f.fullMarkdown;if(!c){const de=await nn();if(!rt.current||de.aborted)return;c=de.markdown??""}if(!c){Ot("failed");return}const P=await ms(c);rt.current&&Ot(P?"copied":"failed")},ts=async()=>{if(!f)return;let c=f.fullMarkdown;if(!c){const Be=await nn();if(!rt.current||Be.aborted)return;c=Be.markdown??""}if(!c){Ot("export-failed");return}const P=new Blob([c],{type:"text/markdown;charset=utf-8"}),de=URL.createObjectURL(P),Ve=document.createElement("a");Ve.href=de,Ve.download=`${f.repoName||"project"}-chronicle.md`,document.body.appendChild(Ve),Ve.click(),Ve.remove(),URL.revokeObjectURL(de)},ns=async c=>(Qe.current=null,e!=null&&e.repoPath&&vt(e.repoPath),!!await M(c)),sn=async()=>{Qe.current=null,e!=null&&e.repoPath&&vt(e.repoPath),await $(),Ie(!1)};if(d&&!f||D)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-8",children:[t.jsx("div",{className:"bl-spinner"}),t.jsx("span",{className:"text-[13px]",style:{color:"var(--muted)"},children:"正在聚合开发 Agent 产物、任务交付与 Git 拓扑,梳理软件开发历程…"})]});if(l&&!f)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-8",children:[t.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--accent)"},children:"加载开发历程失败"}),t.jsx("div",{className:"text-[12.5px] max-w-md text-center",style:{color:"var(--muted)"},children:l}),t.jsx("button",{type:"button",onClick:()=>void y(!0),className:"sheet-btn sheet-btn-primary",children:"重新加载"})]});if(!f)return null;const rn=Bt[f.primaryOrigin],Dt=f.aiPowered?`AI 辅助编排(${f.aiProvider||"内置模型"})`:f.sourceMode==="agent-only"?"仅外部 Agent / 本地静态(零 API)":f.primaryOrigin==="agent-chronicle"?"原开发 Agent 一手档案驱动":"本地 Git 拓扑与已沉淀产物驱动",an=!!(f.agentChronicleSource&&f.agentChronicleSource!=="repo-file"),on=f.agentChronicleSource==="repo-file",cn=_n(te),ln=Object.keys(Te).length>0;return t.jsxs("div",{className:"bl-ch-stage","data-testid":"chronicle-stage",children:[t.jsxs("header",{className:"bl-ch-header","data-testid":"chronicle-header",children:[t.jsxs("div",{className:"bl-ch-header-row1",children:[t.jsxs("div",{className:"bl-ch-header-identity",children:[t.jsxs("span",{className:"caps bl-ch-repo-title shrink-0",children:[f.repoName," · PROJECT CHRONICLE"]}),t.jsx("span",{className:"bl-ch-badge shrink-0","data-tone":rn.tone,"data-testid":"chronicle-primary-origin",children:rn.shortLabel}),t.jsx("span",{className:"bl-ch-engine-pill shrink-0","data-testid":"chronicle-engine-status",title:f.generatedAt?`${Dt} · 更新于 ${Tt(f.generatedAt)}`:Dt,children:Dt}),f.aiEnriching&&t.jsxs("span",{className:"bl-ch-enriching-pill shrink-0","data-testid":"chronicle-ai-enriching-pill",role:"status","aria-live":"polite",children:[t.jsx("span",{className:"bl-ch-enriching-dot","aria-hidden":"true"}),t.jsxs("span",{children:["✦ AI 正在通俗润色节点…",typeof f.aiPendingCount=="number"&&f.aiPendingCount>0?`(剩余 ${f.aiPendingCount})`:""]})]}),on&&t.jsx("span",{className:"bl-ch-engine-pill shrink-0","data-testid":"chronicle-repo-file-badge",title:"来自仓库内 .branch-lens/chronicle.* 文件,只读不可在界面直接删除",children:"仓内只读"}),fe&&t.jsx("span",{className:"bl-ch-engine-pill bl-ch-trunk-limit-pill shrink-0","data-testid":"chronicle-trunk-limit-hint",title:"完整提交模式默认仅展示最近 120 条主干提交,以保证大仓库画布 60fps 流畅交互",children:"仅展示最近 120 条主干提交"}),!Es(f)&&t.jsx("p",{className:"bl-ch-overview-inline","data-testid":"chronicle-overview-inline",title:f.overview,children:f.overview})]}),t.jsxs("div",{className:"bl-ch-stats-inline","aria-label":"开发历程统计",title:f.generatedAt?`更新于 ${Tt(f.generatedAt)} · 三层来源分布:Agent ${f.stats.agentNativeCount} / 任务 ${f.stats.branchLensTaskCount} / AI·Git ${f.stats.aiOrStaticCount}`:void 0,children:[t.jsxs("span",{children:[t.jsx("strong",{className:"mono",children:f.stats.totalPhases})," 阶段"]}),t.jsx("span",{className:"bl-ch-stat-dot","aria-hidden":"true",children:"·"}),t.jsxs("span",{children:[t.jsx("strong",{className:"mono",children:f.stats.totalNodes})," 节点"]}),t.jsx("span",{className:"bl-ch-stat-dot","aria-hidden":"true",children:"·"}),t.jsxs("span",{children:[t.jsx("strong",{className:"mono",children:f.stats.mergedCount})," 已合入"]}),t.jsx("span",{className:"bl-ch-stat-sep","aria-hidden":"true",children:"|"}),t.jsxs("span",{className:"mono bl-ch-stats-sources-inline",children:["Agent ",f.stats.agentNativeCount," · 任务 ",f.stats.branchLensTaskCount," · Git"," ",f.stats.aiOrStaticCount]})]})]}),(f.aiFallbackReason||ve||He||l)&&t.jsxs("div",{className:"bl-ch-notices",children:[He&&t.jsxs("div",{className:"bl-ch-notice flex items-center justify-between gap-2","data-testid":"chronicle-focus-banner",children:[t.jsxs("span",{className:"truncate",children:["当前聚焦子树:",t.jsx("strong",{children:He.title}),"(仅展示该节点及派生分支,镜头保持原位)"]}),t.jsx("button",{type:"button","data-testid":"chronicle-exit-focus-btn",onClick:()=>we(T,null),className:"bl-pill-action text-[11px] shrink-0",children:"退出聚焦"})]}),f.aiFallbackReason&&t.jsx("div",{className:"bl-ch-notice","data-tone":"info","data-testid":"chronicle-fallback-notice",children:t.jsxs("span",{children:["提示:",f.aiFallbackReason]})}),ve&&t.jsx("div",{className:"bl-ch-notice","data-tone":"warn","data-testid":"chronicle-stale-notice",children:t.jsx("span",{children:"部分原开发 Agent 资料基于旧提交(已在对应节点标注「旧提交」),仍可正常追溯并随时点击「重新梳理历程」。"})}),l&&t.jsx("div",{className:"bl-ch-notice","data-tone":"error",children:t.jsxs("span",{children:["最近一次操作失败:",l]})})]}),t.jsxs("div",{className:"bl-ch-toolbar","data-testid":"chronicle-toolbar",children:[t.jsxs("div",{className:"bl-ch-toolbar-left",children:[t.jsx("div",{className:"bl-ch-view-switch bl-ch-granularity-switch",role:"radiogroup","aria-label":"开发历程聚合粒度","data-testid":"chronicle-granularity-switch",children:qr.map(c=>{const P=a&&c.id!=="requirement";return t.jsx("button",{type:"button",role:"radio","aria-checked":n===c.id,disabled:P,"data-testid":`chronicle-granularity-${c.id}`,"data-active":n===c.id?"true":"false",onClick:()=>{P||r(c.id)},className:"bl-ch-switch-btn disabled:opacity-40 disabled:cursor-not-allowed",title:P?"当前工作区尚未产生 Git 提交,首次提交后解锁":c.title,children:c.label},c.id)})}),t.jsxs("div",{className:"bl-ch-view-switch",role:"tablist","aria-label":"历程视图切换",children:[t.jsx("button",{type:"button",role:"tab","aria-selected":L==="swimlane","data-testid":"chronicle-tab-swimlane",onClick:()=>re(w,"swimlane",!0),className:"bl-ch-switch-btn","data-active":L==="swimlane"?"true":"false",title:"演进泳道图",children:"泳道"}),t.jsx("button",{type:"button",role:"tab","aria-selected":L==="timeline","data-testid":"chronicle-tab-timeline",onClick:()=>re(w,"timeline",!0),className:"bl-ch-switch-btn","data-active":L==="timeline"?"true":"false",title:"纵向编年汇报",children:"编年"}),t.jsx("button",{type:"button",role:"tab","aria-selected":L==="trace","data-testid":"chronicle-view-trace",onClick:()=>re(w,"trace",!0),className:"bl-ch-switch-btn","data-active":L==="trace"?"true":"false",title:"执行轨迹检查器(三轨时间轴与单步明细)",children:"轨迹"})]})]}),L!=="trace"&&t.jsxs("div",{className:"bl-ch-toolbar-mid",children:[t.jsxs("div",{className:"bl-ch-search-box","data-active":C?"true":"false",children:[t.jsx("span",{className:"bl-ch-search-icon","aria-hidden":"true",children:"⌕"}),t.jsx("input",{ref:S,type:"text",value:W,onChange:Le,onKeyDown:je,placeholder:"定位节点 / 分支 / SHA…","aria-label":"搜索历程节点","data-testid":"chronicle-search-input",className:"bl-ch-search-input"}),C?t.jsxs("div",{className:"bl-ch-search-controls",children:[t.jsx("span",{className:"bl-ch-search-count mono","data-testid":"chronicle-search-count","data-empty":N.length===0?"true":"false",children:N.length>0?`${q+1}/${N.length}`:"0/0"}),N.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>Ee(q-1),"aria-label":"上一条匹配",title:"上一条匹配 (Shift+Enter)","data-testid":"chronicle-search-prev",className:"bl-ch-search-btn",children:"↑"}),t.jsx("button",{type:"button",onClick:()=>Ee(q+1),"aria-label":"下一条匹配",title:"下一条匹配 (Enter)","data-testid":"chronicle-search-next",className:"bl-ch-search-btn",children:"↓"})]}),t.jsx("button",{type:"button",onClick:le,"aria-label":"清空搜索并恢复视角",title:"清空搜索并恢复视角 (Esc)","data-testid":"chronicle-search-clear",className:"bl-ch-search-btn",children:"×"})]}):t.jsx("kbd",{className:"bl-ch-search-kbd mono","aria-hidden":"true",children:"/"})]}),t.jsxs("div",{className:"bl-ch-filters",children:[t.jsx(Nt,{ariaLabel:"按阶段筛选",testId:"chronicle-filter-phase",value:te.phaseId,defaultValue:"all",minMenuWidth:184,options:[{value:"all",label:`全部阶段 (${f.phases.length})`},...f.phases.map(c=>({value:c.id,label:`${String(c.order).padStart(2,"0")} · ${c.title}`}))],onChange:c=>Z(T,P=>({...P,phaseId:c})),className:"bl-ch-filter-select"}),t.jsx(Nt,{ariaLabel:"按来源筛选",testId:"chronicle-filter-origin",value:te.originGroup,defaultValue:"all",minMenuWidth:164,options:Hr,onChange:c=>Z(T,P=>({...P,originGroup:c})),className:"bl-ch-filter-select"}),t.jsx(Nt,{ariaLabel:"按状态筛选",testId:"chronicle-filter-status",value:te.statusGroup,defaultValue:"all",minMenuWidth:154,options:Kr,onChange:c=>Z(T,P=>({...P,statusGroup:c})),className:"bl-ch-filter-select"}),t.jsx(Nt,{ariaLabel:"按前后端类型筛选",testId:"chronicle-filter-impact",value:te.impact,defaultValue:"all",minMenuWidth:140,options:Wr,onChange:c=>Z(T,P=>({...P,impact:c})),className:"bl-ch-filter-select"}),cn&&t.jsxs("button",{type:"button",onClick:()=>Z(T,Mt),className:"bl-pill-action text-[11.5px] whitespace-nowrap",children:["重置 (",b.length,"/",f.nodes.length,")"]})]})]}),t.jsxs("div",{className:"bl-ch-actions",children:[L!=="trace"&&t.jsxs("button",{type:"button","aria-pressed":Se,"data-active":Se?"true":void 0,onClick:he,"data-testid":"chronicle-phase-summary-toggle",className:"bl-pill-action bl-ch-summary-toggle text-[11.5px] font-medium whitespace-nowrap",title:Se?"当前展示每个阶段 / 每天的说人话总结(点击隐藏以收紧画布高度)":"展开每个阶段 / 每天的说人话 AI 总结",children:[t.jsx("span",{"aria-hidden":"true",children:"✦"}),t.jsx("span",{children:"阶段总结"})]}),L==="swimlane"&&n==="commit"&&t.jsxs("button",{type:"button","aria-pressed":Ce,onClick:()=>ke(T,!Ce),"data-testid":"chronicle-trunk-collapse-toggle",className:"bl-pill-action text-[11.5px] font-medium whitespace-nowrap",style:{color:Ce?"var(--accent)":void 0},title:"开启时折叠无分叉/合入锚点且无标签的常规主干提交,点击折叠胶囊可单段展开",children:["主干精简:",Ce?"开":"关",Ce&&Oe.hiddenCount>0?` (-${Oe.hiddenCount})`:""]}),me!=="idle"&&t.jsx("span",{className:"bl-ch-copy-toast mono shrink-0","data-testid":"chronicle-copy-toast",role:"status","aria-live":"polite",children:me==="copied"?"✓ 已复制":me==="export-failed"?"导出失败":"复制失败"}),t.jsxs("div",{ref:O,className:"bl-ch-more-wrap",children:[t.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":pe,onClick:()=>v(c=>!c),"data-testid":"chronicle-more-menu-btn","data-active":pe||_e?"true":"false",className:"bl-pill-action text-[12px] font-medium whitespace-nowrap",title:"更多操作(自动整理、重新梳理、导出与录入历程)",children:["⋯ 更多",ln?" *":""]}),pe&&t.jsxs("div",{role:"menu","aria-label":"开发历程更多操作","data-testid":"chronicle-more-menu",className:"bl-ch-more-menu",children:[L==="swimlane"&&t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{De(T),v(!1)},"data-testid":"chronicle-auto-arrange-btn",className:"bl-ch-more-item",title:"清空手动拖拽位置并重新适配画布视角",children:[t.jsxs("span",{children:["自动整理",ln?" *":""]}),t.jsx("span",{className:"bl-ch-more-hint",children:"重置布局"})]}),t.jsx("button",{type:"button",role:"menuitem",disabled:d,onClick:()=>{v(!1),Qe.current=null,e!=null&&e.repoPath&&vt(e.repoPath,n),y(!0,n)},"data-testid":"chronicle-refresh-btn",className:"bl-ch-more-item",children:t.jsx("span",{children:d?"梳理中…":"↻ 重新梳理历程"})}),t.jsx("div",{className:"bl-ch-more-sep",role:"separator"}),t.jsx("button",{type:"button",role:"menuitem",disabled:ne,onClick:()=>void es(),"data-testid":"chronicle-copy-md-btn",className:"bl-ch-more-item",children:t.jsx("span",{children:ne?"拉取 Markdown 中…":me==="copied"?"✓ 已复制 Markdown":me==="failed"?"复制失败":"复制 .md"})}),t.jsx("button",{type:"button",role:"menuitem",disabled:ne,onClick:()=>{v(!1),ts()},"data-testid":"chronicle-download-md-btn",className:"bl-ch-more-item",children:t.jsx("span",{children:ne?"准备导出中…":"导出开发历程 (.md)"})}),t.jsx("div",{className:"bl-ch-more-sep",role:"separator"}),t.jsx("button",{type:"button",role:"menuitem",onClick:()=>{Ie(c=>!c),v(!1)},"data-testid":"chronicle-toggle-submit-btn",className:"bl-ch-more-item","data-active":_e?"true":"false",children:t.jsx("span",{children:"录入 / 更新历程"})}),an&&t.jsx("button",{type:"button",role:"menuitem",disabled:m,onClick:()=>{v(!1),sn()},"data-testid":"chronicle-toolbar-clear-btn",className:"bl-ch-more-item bl-ch-more-item-danger",children:t.jsx("span",{children:"清除私有提交"})})]})]})]})]}),_e&&t.jsx(Ys,{submitting:m,canClearPrivate:an,isRepoFileSource:on,onSubmit:ns,onClear:sn,onClose:()=>Ie(!1)})]}),t.jsxs("div",{className:"bl-ch-workspace",children:[t.jsxs("div",{className:"bl-ch-main-pane","data-granularity-switching":R?"true":"false",children:[A&&d&&t.jsxs("div",{className:"bl-ch-granularity-loading-bar","data-testid":"chronicle-granularity-loading",role:"status","aria-live":"polite",children:[t.jsx("span",{className:"bl-ch-granularity-spinner","aria-hidden":"true"}),t.jsx("span",{children:G?"正在后台同步最新粒度数据…":"正在切换并聚合当前粒度历程…"})]}),(L==="trace"||p===w)&&t.jsx("div",{"data-testid":"chronicle-trace-keepalive-pane","data-active":L==="trace"?"true":"false",hidden:L!=="trace",style:L==="trace"?void 0:{display:"none"},className:L==="trace"?"flex-1 min-h-0 min-w-0 flex flex-col overflow-hidden":void 0,children:t.jsx(o.Suspense,{fallback:t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3",children:[t.jsx("div",{className:"bl-spinner"}),t.jsx("span",{className:"text-xs",style:{color:"var(--muted)"},children:"正在加载执行轨迹检查器…"})]}),children:t.jsx(Dr,{mode:"chronicle",repoKey:w,target:Jn,onTargetChange:F,onBackToCanvas:Un},w)})}),L!=="trace"&&(b.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-10 text-center",children:[t.jsx("div",{className:"text-[14px] font-medium",children:"当前筛选条件下暂无匹配节点"}),t.jsx("div",{className:"text-[12px]",style:{color:"var(--muted)"},children:"尝试放宽阶段、来源、状态或前后端类型筛选条件。"}),cn&&t.jsx("button",{type:"button",onClick:()=>Z(g,Mt),className:"sheet-btn",children:"重置全部筛选"})]}):L==="swimlane"?t.jsx(Qn,{repoKey:g,baseBranch:f.baseBranch,phases:f.phases,nodes:f.nodes,edges:f.edges,filters:te,selectedNodeId:R?null:ce,focusedNodeId:U,trunkCollapseEnabled:X,expandedTrunkSegmentIds:tt,collapsedBranchIds:lt,lockedPositions:Te,trunkFold:ee,arrangeSeq:se,canvasHandleRef:h,searchMatchIds:z,activeDshSessionId:u,showPhaseSummary:Se,onSelectNode:Ue,onFocusNode:Ke,onToggleCollapseBranch:ot,onExpandTrunkSegment:dt,onPersistCamera:Ge,onCommitCardDrag:Ze}):t.jsx(Or,{phases:f.phases,nodes:b,selectedNodeId:R?null:ce,showPhaseSummary:Se,onSelectNode:xt}))]}),L!=="trace"&&Me&&!R&&t.jsx(Gs,{node:Me,baseBranch:f.baseBranch,phase:Re,hasForkChildren:nt,isFocused:U===Me.id,onFocusNode:Ke,onOpenTrace:c=>{var de,Ve,Be,qe;const P=c.evidence.taskId?"branch-lens-task":((de=c.requirementMeta)==null?void 0:de.conversationSource)==="dsh"||c.origin.conversationSource==="dsh"?"dsh":((Ve=c.requirementMeta)==null?void 0:Ve.conversationSource)==="codex"||c.origin.conversationSource==="codex"?"codex":"git";F({source:P,sessionId:(Be=c.requirementMeta)==null?void 0:Be.sessionId,taskId:c.evidence.taskId,nodeId:c.id,turnIndex:(qe=c.requirementMeta)==null?void 0:qe.turnIndex}),re(w,"trace",!0)},onClose:kt},Me.id)]})]})};export{Qr as ChronicleStage};