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.
- package/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/dist/cli.js +5620 -3272
- package/dist/cpuWorker.js +1988 -0
- package/dist/launcher.d.ts +68 -15
- package/dist/launcher.js +6966 -4617
- package/dist/web/assets/AiAnnotator-CCj1dKr0.js +1 -0
- package/dist/web/assets/ChronicleStage-Cznb0SLP.js +30 -0
- package/dist/web/assets/CodeDiffStage-BAkeoFAz.js +3 -0
- package/dist/web/assets/CodexSessionBindingFields-DkR0bGRW.js +1 -0
- package/dist/web/assets/CompareStage-6mAMGmE9.js +2 -0
- package/dist/web/assets/CompareStage-DMkd60zd.css +1 -0
- package/dist/web/assets/DoctorChecklist-cmvmLa4s.js +1 -0
- package/dist/web/assets/ExecutionTraceView-BuKMTJLz.js +1 -0
- package/dist/web/assets/LiquidSelect-BcHivJrw.js +1 -0
- package/dist/web/assets/LogDrawer-hywJ_5f2.js +1 -0
- package/dist/web/assets/{PrDraftModal-DpkvQrsw.js → PrDraftModal-CKdIoZTF.js} +2 -12
- package/dist/web/assets/ResponsiveMatrixStage-IZfS6JC4.js +1 -0
- package/dist/web/assets/RouteBar-CbnzrFM4.js +1 -0
- package/dist/web/assets/SafeMarkdownBody-DAg3yHJ5.js +1 -0
- package/dist/web/assets/SettingsModal-CfMz0_4F.js +4 -0
- package/dist/web/assets/{TaskComposer-EPlw68x5.js → TaskComposer-CO8tCqFg.js} +5 -5
- package/dist/web/assets/TaskPanel--8Ima6hX.js +5 -0
- package/dist/web/assets/VerificationSummaryCard-D5fnYeAl.js +1 -0
- package/dist/web/assets/VerificationView-OYxRYOMD.js +1 -0
- package/dist/web/assets/WelcomeDoctorView-DCmfWMhg.js +1 -0
- package/dist/web/assets/annotate-Cnu9ugkR.css +1 -0
- package/dist/web/assets/doctor-BvSbLVK8.css +1 -0
- package/dist/web/assets/index-B76NgI6o.css +1 -0
- package/dist/web/assets/index-CuRBE0Be.js +3 -0
- package/dist/web/assets/logs-_ws1o3oK.css +1 -0
- package/dist/web/assets/pickedElement-DWJDcr9q.js +1 -0
- package/dist/web/assets/settings-DaDpE3K8.css +1 -0
- package/dist/web/assets/stageCache-nD7q31wP.js +1 -0
- package/dist/web/assets/tasks-BYC2JuuF.css +1 -0
- package/dist/web/assets/vendor-icons-BeN0on9X.js +371 -0
- package/dist/web/assets/vendor-markdown-COdlM-u6.js +14 -0
- package/dist/web/assets/vendor-react-CIotE-6Q.js +49 -0
- package/dist/web/index.html +9 -2
- package/package.json +1 -1
- package/dist/web/assets/AiAnnotator-zRRz7Hd_.js +0 -21
- package/dist/web/assets/ChronicleStage-DU21HBDf.js +0 -30
- package/dist/web/assets/CodeDiffStage-DAhgBZQK.js +0 -23
- package/dist/web/assets/CodexSessionBindingFields-DiO2jbce.js +0 -1
- package/dist/web/assets/CompareStage-BJ8Jwxc8.js +0 -37
- package/dist/web/assets/DoctorChecklist-C6zhApVB.js +0 -11
- package/dist/web/assets/ExecutionTraceView-BJm89dCg.js +0 -21
- package/dist/web/assets/ResponsiveMatrixStage-Df2JDBnc.js +0 -6
- package/dist/web/assets/RouteBar-DgHUPTd-.js +0 -1
- package/dist/web/assets/SafeMarkdownBody-CqB1wBws.js +0 -14
- package/dist/web/assets/SettingsModal-BUP_V44u.js +0 -9
- package/dist/web/assets/VerificationView-CQZlUjOa.js +0 -1
- package/dist/web/assets/WelcomeDoctorView-Cdemm1Gq.js +0 -6
- package/dist/web/assets/book-open-J84boHt9.js +0 -6
- package/dist/web/assets/chevron-up-BNxyonTB.js +0 -6
- package/dist/web/assets/external-link-BOTi_FMk.js +0 -6
- package/dist/web/assets/git-commit-horizontal-fzBJ5V7a.js +0 -11
- package/dist/web/assets/index-DOHn8ygK.js +0 -254
- package/dist/web/assets/index-_5gNstnt.css +0 -1
- package/dist/web/assets/info-kubeg88y.js +0 -6
- package/dist/web/assets/pickedElement-p10cew5p.js +0 -11
- package/dist/web/assets/search-CZutG0ij.js +0 -6
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as i,j as e}from"./vendor-react-CIotE-6Q.js";import{u as $e,J as Xe,S as Ue,c as ls,K as ns,j as is,a as ke,w as cs,k as Le}from"./index-CuRBE0Be.js";import{A as ds}from"./presets-DiVmkZ02.js";import{T as De,s as Ye,b as Te,c as Ie,w as os,C as ps,a as us,e as Re,l as xs,F as fs,j as Ze,O as Qe,ab as hs,ac as ms,ad as vs,ae as gs}from"./vendor-icons-BeN0on9X.js";import{b as bs,c as fe,s as Ve}from"./stageCache-nD7q31wP.js";function js(a){switch(a){case"功能新增":return{background:"var(--diff-add-bg)",color:"var(--diff-add-ink)"};case"体验与逻辑优化":return{background:"var(--accent-soft)",color:"var(--accent)"};case"问题修复":return{background:"rgba(217, 119, 6, 0.14)",color:"#b45309"};case"权限与安全":return{background:"var(--redline-soft, var(--diff-del-bg))",color:"var(--redline, var(--diff-del-ink))"};case"性能与稳定性":return{background:"rgba(79, 70, 229, 0.12)",color:"#4f46e5"};default:return{background:"var(--surface)",color:"var(--muted)"}}}function ys(a,c){switch(a){case"backend":return"后端";case"frontend":return"前端";case"config":return"配置";case"test":return"测试";case"other":return"其他";default:return c?"前端":"代码"}}function ks(a){const c=a.charAt(0).toUpperCase();return c==="A"?{background:"var(--diff-add-bg)",color:"var(--diff-add-ink)"}:c==="D"?{background:"var(--diff-del-bg)",color:"var(--diff-del-ink)"}:{background:"var(--accent-soft)",color:"var(--accent)"}}const Ns=({baseLabel:a,targetLabel:c,files:x,filesLoading:h,filesError:u,explanation:r,explainLoading:A,explainError:F,onRefreshExplanation:m,onJumpToFileCode:z,onSwitchToCode:N})=>{var T,p,V,O,K;const C=$e(o=>o.pushToast),[L,B]=i.useState(!1),[R,re]=i.useState(!1),[_,Fe]=i.useState(!0),[G,Z]=i.useState(!1),j=r==null?void 0:r.plainSummary,H=((T=j==null?void 0:j.headline)==null?void 0:T.trim())||((p=r==null?void 0:r.overview)==null?void 0:p.trim())||"",y=(j==null?void 0:j.highlights)??[],le=(j==null?void 0:j.attentionPoints)??[],f=i.useMemo(()=>r?Xe(r,"本地静态总结"):null,[r]),Ae=i.useMemo(()=>{const o=new Map;for(const w of y)for(const ne of w.relatedFiles??[])o.has(ne)||o.set(ne,w.title);return o},[y]),he=i.useMemo(()=>j||!r?[]:[...r.contractChanges,...r.risks],[j,r]),U=async()=>{await ls(ds)?(Z(!0),setTimeout(()=>Z(!1),2e3),C({tone:"success",title:"已复制 Agent 联动规范",detail:"可粘贴到业务仓库的 AGENTS.md、CLAUDE.md 或 Cursor Rules 中。",durationMs:4500})):C({tone:"warning",title:"复制失败",detail:"当前环境不支持自动写入剪贴板,请前往设置页展开模板手动复制。",durationMs:4e3})},me=((r==null?void 0:r.reportSha)||((V=r==null?void 0:r.staleReport)==null?void 0:V.headSha)||"").slice(0,7),Q=(r==null?void 0:r.explainSourceMode)==="agent-only"&&(f==null?void 0:f.origin)==="static",$=!!(r!=null&&r.reportMarkdown&&!r.reportStale);return e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto","data-plain-summary-view":"true",style:{background:"var(--bg)"},children:e.jsxs("div",{className:"bl-plain-summary-inner max-w-3xl mx-auto px-6 py-6 space-y-5 text-xs",children:[A&&!r?e.jsxs("div",{className:"bl-plain-card py-12 flex flex-col items-center justify-center gap-2.5",children:[e.jsx("div",{className:"bl-spinner"}),e.jsx("div",{className:"text-sm font-medium",style:{color:"var(--ink)"},children:"正在生成 AI 通俗总结…"}),e.jsx("div",{className:"text-xs",style:{color:"var(--muted)"},children:"将本次代码改动翻译为易懂的业务变化与验收建议"})]}):F&&!r?e.jsxs("div",{role:"alert",className:"bl-plain-card p-4 flex items-center justify-between gap-3",style:{borderColor:"var(--redline, var(--accent))",background:"var(--redline-soft, var(--diff-del-bg))"},children:[e.jsxs("div",{className:"flex items-start gap-2 min-w-0",style:{color:"var(--redline, var(--diff-del-ink))"},children:[e.jsx(De,{size:15,className:"shrink-0 mt-0.5"}),e.jsx("span",{className:"break-words leading-relaxed",children:F})]}),e.jsxs("button",{type:"button",onClick:m,className:"sheet-btn text-xs shrink-0",children:[e.jsx(Ye,{size:12}),e.jsx("span",{children:"重试"})]})]}):r&&f?e.jsxs(e.Fragment,{children:[r.reportStale&&e.jsxs("section",{role:"status","data-testid":"stale-report-banner",className:"bl-plain-card p-4 space-y-2.5",style:{borderColor:"#d97706",background:"rgba(217, 119, 6, 0.09)"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-start gap-2 min-w-0 flex-1",children:[e.jsx(De,{size:14,className:"shrink-0 mt-0.5",style:{color:"#b45309"}}),e.jsxs("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--ink)"},children:["此外部 Agent 说明基于旧提交"," ",e.jsx("span",{className:"mono font-semibold",children:me||"未知版本"}),",已落后于当前最新代码",r.explainSourceMode!=="agent-only"&&f.origin!=="external-agent"&&e.jsx("span",{children:"(已自动回退展示当前最新版本解读)"}),"。"]})]}),((O=r.staleReport)==null?void 0:O.markdown)&&e.jsxs("button",{type:"button","aria-expanded":R,"data-toggle-stale-report":"true",onClick:()=>re(o=>!o),className:"sheet-btn text-[11.5px] shrink-0",style:{height:28,padding:"0 10px"},children:[R?e.jsx(Te,{size:12}):e.jsx(Ie,{size:12}),e.jsx("span",{children:"对照查看旧版 Agent 说明"})]})]}),R&&((K=r.staleReport)==null?void 0:K.markdown)&&e.jsx("div",{"data-stale-report-markdown":"true",className:"p-3 rounded-lg max-h-[320px] overflow-y-auto",style:{background:"var(--bg)",border:"1px solid var(--hair-strong)"},children:e.jsx(Ue,{content:r.staleReport.markdown})})]}),Q&&e.jsxs("section",{role:"status","data-testid":"agent-only-empty-guide",className:"bl-plain-card p-4 flex items-center justify-between gap-3 flex-wrap",style:{background:"var(--surface)"},children:[e.jsxs("div",{className:"flex items-start gap-2 min-w-0 flex-1",children:[e.jsx(os,{size:14,className:"shrink-0 mt-0.5",style:{color:"var(--accent)"}}),e.jsxs("div",{className:"space-y-0.5 text-[12px] leading-relaxed",children:[e.jsx("div",{className:"font-medium",style:{color:"var(--ink)"},children:"当前策略为「仅外部 Agent(零 API)」,尚无匹配最新提交的 Agent 说明"}),e.jsx("div",{className:"text-[11.5px]",style:{color:"var(--muted)"},children:"可将联动规范粘贴至仓库 AGENTS.md / CLAUDE.md,让开发 Agent 提交后自动上报通俗说明。"})]})]}),e.jsxs("button",{type:"button",onClick:()=>void U(),className:"sheet-btn sheet-btn-primary text-xs shrink-0",children:[G?e.jsx(ps,{size:12}):e.jsx(us,{size:12}),e.jsx("span",{children:G?"已复制规范":"一键复制 Agent 联动规范"})]})]}),e.jsxs("section",{className:"bl-plain-card p-5 space-y-3","data-plain-headline":"true","aria-label":"本次改动通俗结论",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"caps inline-flex items-center gap-1.5",style:{color:"var(--accent)"},children:[e.jsx(Re,{size:13}),e.jsx("span",{children:"核心变化一句话总结"})]}),e.jsx("span",{className:"mono text-[10.5px] px-2 py-0.5 rounded-full font-medium","data-explain-source-badge":f.origin,"data-plain-source":f.isAi?"ai":"static",style:f.isAi?{background:"var(--accent-soft)",color:"var(--accent)"}:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair-strong)"},children:f.label}),f.sourceChannel&&e.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair-strong)"},children:f.sourceChannel}),f.origin==="builtin-agent"&&r.aiModel&&e.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair)"},children:r.aiModel}),r.cached&&e.jsx("span",{className:"mono text-[10.5px] px-2 py-0.5 rounded-full",style:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair)"},children:"已命中缓存"})]}),e.jsxs("span",{className:"mono text-[11px]",style:{color:"var(--faint)"},children:[a," → ",c]})]}),e.jsx("h2",{className:"text-[17px] font-semibold leading-snug break-words",style:{color:"var(--ink)"},children:H||"已汇总本次分支间的主要业务与逻辑变动。"}),!r.aiPowered&&r.fallbackReason&&e.jsxs("div",{role:"status","data-testid":"plain-fallback-banner",className:"p-2.5 rounded-lg text-[11.5px] leading-relaxed flex items-center justify-between gap-3 flex-wrap",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)",color:"var(--muted)"},children:[e.jsx("span",{className:"min-w-0 flex-1",children:r.fallbackReason}),e.jsx("button",{type:"button",onClick:()=>$e.getState().setSettingsOpen(!0,"ai"),className:"bl-card-action shrink-0 font-medium",style:{color:"var(--accent)"},children:"去配置 AI →"})]})]}),y.length>0&&e.jsxs("section",{className:"space-y-2.5","aria-label":"主要业务变化",children:[e.jsx("div",{className:"flex items-center justify-between px-0.5",children:e.jsxs("span",{className:"caps",children:["主要业务变化(",y.length,")"]})}),e.jsx("div",{className:"space-y-3",children:y.map((o,w)=>e.jsxs("article",{"data-plain-highlight":w,className:"bl-plain-card p-4 space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[e.jsx("span",{className:"text-[11px] font-semibold px-2 py-0.5 rounded-full shrink-0",style:js(o.category),children:o.category}),e.jsx("h3",{className:"text-[14px] font-semibold break-words",style:{color:"var(--ink)"},children:o.title})]}),o.relatedFiles&&o.relatedFiles.length>0&&e.jsxs("button",{type:"button",onClick:()=>B(!0),className:"mono text-[10.5px] hover:underline underline-offset-2 shrink-0",style:{color:"var(--faint)"},children:["关联 ",o.relatedFiles.length," 个文件"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2.5",children:[e.jsxs("div",{className:"p-2.5 rounded-lg space-y-1",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[e.jsx("div",{className:"caps text-[10px]",children:"原来 vs 现在"}),e.jsx("p",{className:"text-[12.5px] leading-relaxed break-words",style:{color:"var(--ink)"},children:o.whatChanged})]}),e.jsxs("div",{className:"p-2.5 rounded-lg space-y-1",style:{background:"var(--surface)",border:"1px solid var(--hair)"},children:[e.jsx("div",{className:"caps text-[10px]",style:{color:"var(--accent)"},children:"对用户 / 业务的影响"}),e.jsx("p",{className:"text-[12.5px] leading-relaxed break-words",style:{color:"var(--ink)"},children:o.userImpact})]})]})]},`${o.title}-${w}`))})]}),le.length>0&&e.jsxs("section",{className:"bl-plain-card p-4 space-y-2.5","data-plain-attention":"true","aria-label":"验收与注意事项",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xs,{size:14,style:{color:"var(--accent)"}}),e.jsx("span",{className:"caps",children:"验收与注意事项"})]}),e.jsx("ol",{className:"space-y-2",children:le.map((o,w)=>e.jsxs("li",{className:"flex items-start gap-2.5 text-[12.5px] leading-relaxed",style:{color:"var(--ink)"},children:[e.jsx("span",{className:"mono text-[10.5px] font-semibold px-1.5 py-0.5 rounded shrink-0 mt-0.5",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:String(w+1).padStart(2,"0")}),e.jsx("span",{className:"break-words",children:o})]},w))})]}),he.length>0&&e.jsxs("section",{className:"bl-plain-card p-4 space-y-2",children:[e.jsx("div",{className:"caps",children:"关键变化与注意事项"}),e.jsx("ul",{className:"space-y-1.5 pl-4 list-disc text-[12.5px] leading-relaxed",style:{color:"var(--ink)"},children:he.map((o,w)=>e.jsx("li",{children:o},w))})]}),$&&r.reportMarkdown&&e.jsxs("section",{className:"bl-plain-card overflow-hidden","data-agent-report-markdown":"true","aria-label":"Agent 详尽说明文档",children:[e.jsxs("button",{type:"button","aria-expanded":_,onClick:()=>Fe(o=>!o),className:"w-full px-4 py-3 flex items-center justify-between gap-3 text-left",style:{background:"var(--surface)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[_?e.jsx(Te,{size:14}):e.jsx(Ie,{size:14}),e.jsx(fs,{size:13,style:{color:"var(--accent)"}}),e.jsx("span",{className:"font-semibold text-[12.5px]",style:{color:"var(--ink)"},children:"Agent 详尽说明文档"}),r.agentName&&e.jsxs("span",{className:"mono text-[10.5px]",style:{color:"var(--muted)"},children:["· ",r.agentName]})]}),e.jsx("span",{className:"text-[11px] shrink-0",style:{color:"var(--faint)"},children:_?"收起文档":"展开阅读"})]}),_&&e.jsx("div",{className:"p-4",style:{borderTop:"1px solid var(--hair)",background:"var(--bg)"},children:e.jsx(Ue,{content:r.reportMarkdown})})]})]}):!h&&x.length===0?e.jsx("div",{className:"bl-plain-card py-12 text-center text-xs",style:{color:"var(--faint)"},children:"两个分支间暂无文件改动"}):null,e.jsxs("section",{className:"bl-plain-card overflow-hidden","data-plain-files-drawer":"true",children:[e.jsxs("button",{type:"button","aria-expanded":L,onClick:()=>B(o=>!o),className:"w-full px-4 py-3 flex items-center justify-between gap-3 text-left transition-colors",style:{background:L?"var(--surface)":"transparent"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[L?e.jsx(Te,{size:14}):e.jsx(Ie,{size:14}),e.jsx(Ze,{size:13,style:{color:"var(--muted)"}}),e.jsxs("span",{className:"font-medium text-[12.5px]",style:{color:"var(--ink)"},children:["涉及 ",x.length," 个技术改动文件"]}),h&&e.jsx("span",{className:"text-[11px]",style:{color:"var(--faint)"},children:"(读取中…)"})]}),e.jsx("span",{className:"text-[11px] shrink-0",style:{color:"var(--muted)"},children:L?"点击任意文件直达代码差异":"展开查看技术文件"})]}),L&&e.jsx("div",{className:"px-3 pb-3 pt-2 space-y-1.5",style:{borderTop:"1px solid var(--hair)"},children:u?e.jsx("div",{className:"p-2 text-xs",style:{color:"var(--redline, var(--accent))"},children:u}):x.length===0?e.jsx("div",{className:"py-4 text-center text-xs",style:{color:"var(--faint)"},children:"暂无改动文件"}):e.jsxs(e.Fragment,{children:[x.map(o=>{const w=Ae.get(o.path);return e.jsxs("button",{type:"button","data-plain-jump-file":o.path,onClick:()=>z(o.path),className:"bl-codediff-file w-full text-left flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"mono text-[10px] font-semibold px-1 rounded shrink-0",style:ks(o.status),children:o.status.charAt(0).toUpperCase()||"M"}),e.jsx("span",{className:"text-[10.5px] px-1.5 py-0.5 rounded shrink-0",style:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair)"},children:ys(o.category,o.isFrontend)}),e.jsx("span",{className:"mono text-[11.5px] truncate",style:{color:"var(--ink)"},children:o.path}),w&&e.jsxs("span",{className:"text-[10.5px] truncate hidden sm:inline",style:{color:"var(--faint)"},children:["· ",w]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 shrink-0 mono text-[10.5px]",children:[e.jsxs("span",{children:[e.jsxs("span",{style:{color:"var(--diff-add-ink)"},children:["+",o.additions]}),e.jsx("span",{className:"mx-0.5",style:{color:"var(--hair-strong)"},children:"/"}),e.jsxs("span",{style:{color:"var(--diff-del-ink)"},children:["-",o.deletions]})]}),e.jsx("span",{style:{color:"var(--accent)"},children:"看代码 →"})]})]},o.path)}),e.jsx("div",{className:"pt-1.5 flex justify-end",children:e.jsxs("button",{type:"button",onClick:N,className:"bl-card-action inline-flex items-center gap-1 text-[11.5px]",style:{color:"var(--accent)"},children:[e.jsx(Qe,{size:12}),e.jsx("span",{children:"进入完整三栏代码对比 →"})]})})]})})]})]})})},ws=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function Ne(a){const c=a.trim();return c==="/dev/null"?"":c.replace(/^[ab]\//,"")}function Cs(a){const c=[];let x=0;for(;x<a.length;){const h=a[x];if(h.kind==="context"){c.push({left:h,right:h}),x+=1;continue}if(h.kind==="meta"){c.push({left:h,right:null}),x+=1;continue}const u=[];for(;x<a.length&&a[x].kind==="del";)u.push(a[x]),x+=1;const r=[];for(;x<a.length&&a[x].kind==="add";)r.push(a[x]),x+=1;const A=Math.max(u.length,r.length);for(let F=0;F<A;F+=1)c.push({left:u[F]??null,right:r[F]??null})}return c}function ze(a){a&&(a.splitRows=Cs(a.lines))}function Ss(a){if(!a||!a.trim())return[];const c=a.replace(/\r\n/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`);c.length>0&&c[c.length-1]===""&&c.pop();const x=[];let h=null,u=null,r=0,A=0;const F=()=>(h||(h={headerLines:[],oldPath:"",newPath:"",isBinary:!1,hunks:[]},x.push(h)),h);for(const m of c){if(m.startsWith("diff --git ")){ze(u),u=null;const N=m.slice(11).split(" ");h={headerLines:[m],oldPath:Ne(N[0]||""),newPath:Ne(N[1]||""),isBinary:!1,hunks:[]},x.push(h);continue}const z=ws.exec(m);if(z){ze(u);const N=F(),C=Number(z[1]),L=z[2]===void 0?1:Number(z[2]),B=Number(z[3]),R=z[4]===void 0?1:Number(z[4]);r=C,A=B,u={header:m,oldStart:C,oldCount:L,newStart:B,newCount:R,lines:[],splitRows:[]},N.hunks.push(u);continue}if(!u){const N=F();N.headerLines.push(m),m.startsWith("--- ")?N.oldPath=Ne(m.slice(4)):m.startsWith("+++ ")?N.newPath=Ne(m.slice(4)):(m.startsWith("Binary files ")||m==="GIT binary patch")&&(N.isBinary=!0);continue}m.startsWith("+")?u.lines.push({kind:"add",oldLine:null,newLine:A++,text:m.slice(1)}):m.startsWith("-")?u.lines.push({kind:"del",oldLine:r++,newLine:null,text:m.slice(1)}):m.startsWith("\\")?u.lines.push({kind:"meta",oldLine:null,newLine:null,text:m}):u.lines.push({kind:"context",oldLine:r++,newLine:A++,text:m.startsWith(" ")?m.slice(1):m})}return ze(u),x}const Fs=120,Ke=22,As=28,Ms=56,Se=600,Es=8,Ls=16;function qe(a,c){const x=a.length-1;if(x<=0||c<=0)return 0;let h=0,u=x-1;for(;h<u;){const r=h+u+1>>1;a[r]<=c?h=r:u=r-1}return h}function Je(a,c,x,h){const u=a.length-1;if(u<=0)return{start:0,end:0};const r=Math.max(0,c),A=x>0?x:Se,F=qe(a,r),m=qe(a,r+A);return{start:Math.max(0,F-h),end:Math.min(u,m+1+h)}}const Ts=[{id:"all",label:"全部"},{id:"backend",label:"后端"},{id:"frontend",label:"前端"},{id:"config-test",label:"配置测试"}];function we(a){return a.category==="backend"?"backend":a.category==="frontend"||!a.category&&a.isFrontend?"frontend":"config-test"}function Ce(a,c){switch(a){case"backend":return"后端";case"frontend":return"前端";case"config":return"配置";case"test":return"测试";case"other":return"其他";default:return c?"前端":"代码"}}function Is(a){const c=a.charAt(0).toUpperCase();return c==="A"?{background:"var(--diff-add-bg)",color:"var(--diff-add-ink)"}:c==="D"?{background:"var(--diff-del-bg)",color:"var(--diff-del-ink)"}:{background:"var(--accent-soft)",color:"var(--accent)"}}const Hs=({baseRef:a,targetRef:c,baseLabel:x,targetLabel:h,changeSummary:u,displayMode:r,onDisplayModeChange:A,initialFilePath:F})=>{const[m,z]=i.useState(ns),N=r??m,[C,L]=i.useState([]),[B,R]=i.useState(!1),[re,_]=i.useState(null),{isHarnessPanel:Fe}=is(),[G,Z]=i.useState("all"),[j,H]=i.useState(null),[y,le]=i.useState(()=>Fe?"unified":"split"),[f,Ae]=i.useState(!0),[he,U]=i.useState(!1),[me,Q]=i.useState(null),[$,T]=i.useState(null),[p,V]=i.useState(null),[O,K]=i.useState(!1),[o,w]=i.useState(null),ne=ke(s=>{var t;return((t=s.repo)==null?void 0:t.repoHash)??null}),Be=ke(s=>{var t,n;return a?((n=(t=s.repo)==null?void 0:t.branches.find(d=>d.ref===a))==null?void 0:n.sha)??null:null}),He=ke(s=>{var t,n;return c?((n=(t=s.repo)==null?void 0:t.branches.find(d=>d.ref===c))==null?void 0:n.sha)??null:null}),Oe=ke(s=>{var t;return(t=s.config)!=null&&t.ai?`${s.config.ai.provider}|${s.config.ai.model}|${s.config.ai.baseUrl}|${s.config.ai.hasApiKey?1:0}`:""}),q=i.useMemo(()=>bs(ne,a,c,Be,He),[ne,a,c,Be,He]),ee=i.useRef(q);ee.current=q;const ve=i.useRef(Oe);ve.current=Oe;const J=i.useRef(new Map),M=i.useRef(0),ie=i.useRef(0),ce=i.useRef(null),Me=i.useRef((u==null?void 0:u.mode)==="code");Me.current=(u==null?void 0:u.mode)==="code";const X=i.useRef(F);X.current=F;const de=i.useRef(null),[Ee,es]=i.useState(Se),ge=i.useCallback(s=>{const t=fe.get(s);if(t)return t;const n={filesLoaded:!1,files:[],selectedFile:null,patchCache:J.current,explanation:null,aiFingerprint:ve.current};return fe.set(s,n),n},[]),oe=i.useCallback(s=>{A?A(s):(z(s),cs(s))},[A]),Y=i.useCallback(async(s,t)=>{if(!a||!c)return;const n=J.current.get(s);if(n){Q(null),U(!1),T(n);return}const d=++ie.current;U(!0),Q(null);try{const l=await Le.getBranchDiff(a,c,s);if(t!==M.current||d!==ie.current)return;const v={patch:l.patch||"",truncated:!!l.truncated};Ve(J.current,s,v),T(v)}catch(l){if(t!==M.current||d!==ie.current)return;Q(l instanceof Error?l.message:String(l)),T(null)}finally{t===M.current&&d===ie.current&&U(!1)}},[a,c]),be=i.useCallback(async(s=!1)=>{if(!a||!c)return;const t=M.current,n=ee.current;K(!0),w(null);try{const d=await Le.explainBranchDiff({baseRef:a,targetRef:c,...s?{forceRefresh:!0}:{}});if(t!==M.current)return;if(V(d),n){const l=ge(n);l.explanation=d,l.aiFingerprint=ve.current}}catch(d){if(t!==M.current)return;w(d instanceof Error?d.message:String(d))}finally{t===M.current&&K(!1)}},[a,c,ge]);i.useEffect(()=>{var n,d;const s=++M.current;if(ie.current+=1,ce.current=null,_(null),Q(null),w(null),Z("all"),!a||!c){J.current=new Map,L([]),H(null),T(null),V(null),R(!1),U(!1),K(!1);return}const t=q?fe.get(q):void 0;if(J.current=t?t.patchCache:new Map,t&&t.filesLoaded){const l=t.files;L(l),R(!1);const v=X.current&&l.some(k=>k.path===X.current)?X.current:void 0,g=t.selectedFile&&l.some(k=>k.path===t.selectedFile)?t.selectedFile:void 0,b=v||g||(Me.current?(n=l.find(k=>we(k)==="backend"))==null?void 0:n.path:void 0)||((d=l[0])==null?void 0:d.path)||null;if(H(b),t.selectedFile=b,b){const k=t.patchCache.get(b);k?(U(!1),T(k)):(T(null),Y(b,s))}else T(null)}else L([]),H(null),T(null),R(!0),Le.getBranchDiff(a,c).then(l=>{var P,W;if(s!==M.current)return;const v=l.files||[];L(v);const g=q?ge(q):null;if(g&&(g.filesLoaded=!0,g.files=v,g.patchCache=J.current),ce.current){g&&(g.selectedFile=ce.current);return}const k=(X.current&&v.some(I=>I.path===X.current)?X.current:void 0)||(Me.current?(P=v.find(I=>we(I)==="backend"))==null?void 0:P.path:void 0)||l.selectedFile||((W=v[0])==null?void 0:W.path)||null;if(H(k),g&&(g.selectedFile=k),k)if(l.selectedFile===k&&l.patch){const I={patch:l.patch,truncated:!!l.truncated};Ve(J.current,k,I),T(I)}else Y(k,s)}).catch(l=>{s===M.current&&_(l instanceof Error?l.message:String(l))}).finally(()=>{s===M.current&&R(!1)});t!=null&&t.explanation&&t.aiFingerprint===ve.current?(V(t.explanation),K(!1)):(V(null),be(!1))},[a,c,q,Y,be,ge]);const Pe=i.useCallback(s=>{if(ce.current=s,H(s),ee.current){const t=fe.get(ee.current);t&&(t.selectedFile=s)}Y(s,M.current)},[Y]),ss=i.useCallback(s=>{if(ce.current=s,Z("all"),oe("code"),H(s),ee.current){const t=fe.get(ee.current);t&&(t.selectedFile=s)}Y(s,M.current)},[oe,Y]),ts=i.useMemo(()=>{const s={all:C.length,backend:0,frontend:0,"config-test":0};for(const t of C)s[we(t)]+=1;return s},[C]),We=i.useMemo(()=>{var t;const s=[{id:"backend",label:"后端",items:[]},{id:"frontend",label:"前端",items:[]},{id:"config-test",label:"配置与测试",items:[]}];for(const n of C){const d=we(n);G!=="all"&&d!==G||(t=s.find(l=>l.id===d))==null||t.items.push(n)}return s.filter(n=>n.items.length>0)},[C,G]),_e=i.useMemo(()=>{const s=new Map;for(const t of(p==null?void 0:p.files)??[])s.set(t.path,t);return s},[p]),pe=i.useMemo(()=>C.find(s=>s.path===j)??null,[C,j]),D=j?_e.get(j)??null:null,ue=i.useMemo(()=>Ss(($==null?void 0:$.patch)||""),[$==null?void 0:$.patch]),se=i.useMemo(()=>p?Xe(p,"本地静态总结"):null,[p]),S=i.useMemo(()=>{const s=[];for(let n=0;n<ue.length;n+=1){const d=ue[n],l=`${d.newPath||d.oldPath}-${n}`;if(d.isBinary){s.push({kind:"binary",key:`${l}:bin`,height:Ms});continue}for(let v=0;v<d.hunks.length;v+=1){const g=d.hunks[v];if(s.push({kind:"hunk",key:`${l}:h-${v}`,header:g.header,hasTopBorder:v>0,height:As}),y==="split")for(let b=0;b<g.splitRows.length;b+=1)s.push({kind:"split",key:`${l}:h-${v}:s-${b}`,row:g.splitRows[b],height:Ke});else for(let b=0;b<g.lines.length;b+=1)s.push({kind:"unified",key:`${l}:h-${v}:u-${b}`,line:g.lines[b],height:Ke})}}const t=new Array(s.length+1);t[0]=0;for(let n=0;n<s.length;n+=1)t[n+1]=t[n]+s[n].height;return{rows:s,offsets:t,totalHeight:t[s.length]}},[ue,y]),te=S.rows.length>Fs,je=y==="split"?Es:Ls,xe=`${j??""}::${y}::${S.rows.length}::${Ee}`,[ye,as]=i.useState({key:"",start:0,end:0}),ae=i.useMemo(()=>te?ye.key===xe?{start:Math.min(ye.start,S.rows.length),end:Math.min(ye.end,S.rows.length)}:Je(S.offsets,0,Ee,je):{start:0,end:S.rows.length},[te,ye,xe,S,Ee,je]);i.useEffect(()=>{de.current&&(de.current.scrollTop=0)},[j,y,a,c]),i.useEffect(()=>{if(N!=="code")return;const s=de.current;if(!s)return;const t=()=>{const d=s.clientHeight>0?s.clientHeight:Se;es(l=>Math.abs(l-d)>=4?d:l)};if(t(),typeof ResizeObserver>"u")return;const n=new ResizeObserver(t);return n.observe(s),()=>n.disconnect()},[N]);const rs=i.useCallback(()=>{if(!te)return;const s=de.current;if(!s)return;const t=s.clientHeight>0?s.clientHeight:Se,n=Je(S.offsets,s.scrollTop,t,je);as(d=>d.key===xe&&d.start===n.start&&d.end===n.end?d:{key:xe,start:n.start,end:n.end})},[te,S.offsets,je,xe]);return!a||!c?e.jsx("div",{className:"flex-1 flex items-center justify-center p-8 text-xs",style:{color:"var(--muted)"},children:"请先在顶部选择原版 A 与对比 B 分支,以查看代码差异与 AI 对应讲解。"}):e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden","data-code-diff-stage":N,children:[e.jsxs("div",{className:"bl-codediff-topbar px-6 py-2 shrink-0 flex items-center justify-between gap-3 flex-wrap text-xs",style:{borderBottom:"1px solid var(--hair)",background:"var(--surface)"},children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap min-w-0 max-w-full",children:[e.jsxs("div",{role:"tablist","aria-label":"后端差异展示模式",className:"bl-surface-tabs inline-flex items-center gap-1 flex-wrap max-w-full",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":N==="plain","data-diff-display":"plain","data-active":N==="plain"?"true":void 0,onClick:()=>oe("plain"),className:"bl-surface-tab",children:[e.jsx(Re,{size:12}),e.jsx("span",{children:"AI 通俗总结"})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":N==="code","data-diff-display":"code","data-active":N==="code"?"true":void 0,onClick:()=>oe("code"),className:"bl-surface-tab",children:[e.jsx(Qe,{size:12}),e.jsx("span",{children:"代码差异"})]})]}),e.jsxs("span",{className:"mono text-[11px] truncate max-w-full",style:{color:"var(--muted)"},children:[x||a," → ",h||c]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap min-w-0 max-w-full",children:[(p==null?void 0:p.cached)&&e.jsx("span",{className:"mono text-[10.5px] px-2 py-0.5 rounded-full",style:{background:"var(--bg)",color:"var(--muted)",border:"1px solid var(--hair-strong)"},children:"已命中缓存"}),p&&se&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mono text-[10.5px] px-2 py-0.5 rounded-full","data-explain-source-badge":se.origin,style:se.isAi?{background:"var(--accent-soft)",color:"var(--accent)"}:{background:"var(--bg)",color:"var(--muted)",border:"1px solid var(--hair)"},children:se.label}),se.sourceChannel&&e.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--bg)",color:"var(--muted)",border:"1px solid var(--hair)"},children:se.sourceChannel})]}),e.jsxs("button",{type:"button",disabled:O,onClick:()=>void be(!0),className:"bl-card-action inline-flex items-center gap-1 text-[11.5px] disabled:opacity-45",style:{color:"var(--accent)"},title:"忽略缓存,重新生成 AI 总结与代码对比讲解",children:[e.jsx(Ye,{size:11,className:O?"animate-spin":void 0}),e.jsx("span",{children:O?"生成中…":"刷新 AI 讲解"})]})]})]}),N==="plain"?e.jsx(Ns,{baseLabel:x||a,targetLabel:h||c,files:C,filesLoading:B,filesError:re,explanation:p,explainLoading:O,explainError:o,onRefreshExplanation:()=>void be(!0),onJumpToFileCode:ss,onSwitchToCode:()=>oe("code")}):e.jsxs("div",{className:"bl-codediff-grid flex-1 min-h-0 overflow-hidden",children:[e.jsxs("aside",{className:"bl-codediff-pane bl-codediff-nav flex flex-col min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"px-3.5 py-2.5 shrink-0 space-y-2",style:{borderBottom:"1px solid var(--hair)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"caps inline-flex items-center gap-1.5",children:[e.jsx(Ze,{size:12}),e.jsx("span",{children:"改动文件"})]}),e.jsx("span",{className:"mono text-[11px]",style:{color:"var(--muted)"},children:String(C.length).padStart(2,"0")})]}),e.jsx("div",{className:"flex items-center gap-1 flex-wrap",role:"tablist","aria-label":"文件分类筛选",children:Ts.map(s=>{const t=ts[s.id],n=G===s.id;return e.jsxs("button",{type:"button",role:"tab","aria-selected":n,onClick:()=>Z(s.id),className:"mono text-[11px] px-2 py-0.5 rounded-full transition-colors",style:{background:n?"var(--accent-soft)":"transparent",color:n?"var(--accent)":"var(--muted)",border:`1px solid ${n?"var(--accent)":"var(--hair)"}`,fontWeight:n?600:450},children:[s.label,t>0?` ${t}`:""]},s.id)})})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-2 space-y-3",children:B?e.jsx("div",{className:"py-8 text-center text-xs",style:{color:"var(--muted)"},children:"正在读取改动文件…"}):re?e.jsx("div",{className:"p-3 text-xs",style:{color:"var(--redline, var(--accent))"},children:re}):We.length===0?e.jsx("div",{className:"py-8 text-center text-xs",style:{color:"var(--faint)"},children:"当前分组下无改动文件"}):We.map(s=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"caps px-2 py-0.5 flex items-center justify-between",children:[e.jsx("span",{children:s.label}),e.jsx("span",{className:"mono text-[10px]",children:s.items.length})]}),s.items.map(t=>{const n=t.path===j,d=_e.get(t.path),l=!!(d&&(d.reviewPoints.length>0||d.impact));return e.jsxs("button",{type:"button","data-diff-file":t.path,"data-active":n?"true":void 0,onClick:()=>Pe(t.path),title:t.path,className:"bl-codediff-file w-full text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"mono text-[10px] font-semibold px-1 rounded shrink-0",style:Is(t.status),children:t.status.charAt(0).toUpperCase()||"M"}),e.jsx("span",{className:"mono text-[11.5px] truncate flex-1",style:{color:n?"var(--accent)":"var(--ink)",fontWeight:n?600:450},children:t.path}),l&&e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full shrink-0",style:{background:"var(--accent)"},title:"含 AI 讲解与审查要点"})]}),e.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2 text-[10.5px] mono",children:[e.jsx("span",{style:{color:"var(--faint)"},children:Ce(t.category,t.isFrontend)}),e.jsxs("span",{className:"shrink-0",children:[e.jsxs("span",{style:{color:"var(--diff-add-ink)"},children:["+",t.additions]}),e.jsx("span",{className:"mx-1",style:{color:"var(--hair-strong)"},children:"/"}),e.jsxs("span",{style:{color:"var(--diff-del-ink)"},children:["-",t.deletions]})]})]})]},t.path)})]},s.id))})]}),e.jsxs("section",{className:"bl-codediff-pane bl-codediff-center flex flex-col min-w-0 min-h-0 overflow-hidden","aria-label":"代码对比视图",children:[e.jsxs("div",{className:"px-4 py-2 shrink-0 flex items-center justify-between gap-3 flex-wrap",style:{borderBottom:"1px solid var(--hair)",background:"var(--surface)"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(hs,{size:13,style:{color:"var(--accent)"},className:"shrink-0"}),e.jsx("span",{className:"mono text-xs font-semibold truncate",style:{color:"var(--ink)"},children:j||`${x||a} → ${h||c}`}),pe&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded shrink-0",style:{background:"var(--bg)",color:"var(--muted)",border:"1px solid var(--hair)"},children:Ce(pe.category,pe.isFrontend)}),e.jsxs("span",{className:"mono text-[11px] shrink-0",children:[e.jsxs("span",{style:{color:"var(--diff-add-ink)"},children:["+",pe.additions]})," ",e.jsxs("span",{style:{color:"var(--diff-del-ink)"},children:["-",pe.deletions]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",role:"group","aria-label":"代码视图模式",children:[e.jsxs("button",{type:"button","aria-pressed":f,"data-diff-wrap":f?"true":"false",onClick:()=>Ae(s=>!s),className:"bl-card-action inline-flex items-center gap-1 text-[11.5px]",style:{color:f?"var(--accent)":"var(--muted)",fontWeight:f?600:450},title:f?"关闭自动折行(长行可在双栏内各自横向滚动)":"开启自动折行,长行完整显示在视口内",children:[e.jsx(ms,{size:12}),e.jsx("span",{children:"自动折行"})]}),e.jsxs("button",{type:"button","aria-pressed":y==="split",onClick:()=>le("split"),className:"bl-card-action inline-flex items-center gap-1 text-[11.5px]",style:{color:y==="split"?"var(--accent)":"var(--muted)",fontWeight:y==="split"?600:450},children:[e.jsx(vs,{size:12}),e.jsx("span",{children:"并排 Split"})]}),e.jsxs("button",{type:"button","aria-pressed":y==="unified",onClick:()=>le("unified"),className:"bl-card-action inline-flex items-center gap-1 text-[11.5px]",style:{color:y==="unified"?"var(--accent)":"var(--muted)",fontWeight:y==="unified"?600:450},children:[e.jsx(gs,{size:12}),e.jsx("span",{children:"统一 Unified"})]})]})]}),($==null?void 0:$.truncated)&&e.jsxs("div",{role:"status",className:"px-4 py-1.5 text-[11.5px] shrink-0 flex items-center gap-2",style:{background:"var(--accent-soft)",color:"var(--accent)",borderBottom:"1px solid var(--hair)"},children:[e.jsx(De,{size:12,className:"shrink-0"}),e.jsx("span",{children:"该文件差异超过单文件展示上限(512 KiB),内容已截断,仅展示前段补丁。"})]}),e.jsx("div",{ref:de,"data-testid":"codediff-scroll-container",onScroll:te?rs:void 0,className:"flex-1 min-h-0 overflow-auto mono text-[11.5px] leading-5",children:he?e.jsx("div",{className:"py-12 text-center text-xs",style:{color:"var(--muted)"},children:"正在加载文件代码差异…"}):me?e.jsx("div",{className:"p-4 text-xs",style:{color:"var(--redline, var(--accent))"},children:me}):j?ue.length===0?e.jsx("div",{className:"py-12 text-center text-xs",style:{color:"var(--faint)"},children:"该文件无文本差异"}):te?e.jsxs("div",{"data-diff-file-body":"true","data-virtualized":"true","data-diff-mode":y,"data-wrap":f?"true":"false",className:y==="unified"&&!f?"min-w-max":"w-full",children:[S.offsets[ae.start]>0&&e.jsx("div",{"aria-hidden":"true","data-virtual-spacer":"top",style:{height:S.offsets[ae.start]}}),S.rows.slice(ae.start,ae.end).map(s=>{var l,v,g,b,k,P,W,I;if(s.kind==="binary")return e.jsx("div",{className:"p-6 text-center text-xs",style:{color:"var(--muted)"},children:"二进制文件已变更(不支持文本差异对比)"},s.key);if(s.kind==="hunk")return e.jsx("div",{className:"px-3 py-1 text-[11px] sticky top-0 z-10",style:{background:"var(--surface)",color:"var(--accent)",borderTop:s.hasTopBorder?"1px solid var(--hair)":void 0,borderBottom:"1px solid var(--hair)"},children:s.header},s.key);if(s.kind==="split"){const{row:E}=s;return e.jsxs("div",{className:"bl-diff-split-row","data-wrap":f?"true":"false",children:[e.jsxs("div",{className:"bl-diff-cell",style:((l=E.left)==null?void 0:l.kind)==="del"?{background:"var(--diff-del-bg)",color:"var(--diff-del-ink)"}:E.left===null?{background:"var(--surface)"}:{color:"var(--ink)"},children:[e.jsx("span",{className:"bl-diff-lineno",children:((v=E.left)==null?void 0:v.oldLine)??""}),e.jsx("span",{className:"bl-diff-sign",children:((g=E.left)==null?void 0:g.kind)==="del"?"-":""}),e.jsx("span",{className:`bl-diff-code ${f?"whitespace-pre-wrap break-all":"whitespace-pre"}`,children:((b=E.left)==null?void 0:b.text)??""})]}),e.jsxs("div",{className:"bl-diff-cell bl-diff-cell-right",style:((k=E.right)==null?void 0:k.kind)==="add"?{background:"var(--diff-add-bg)",color:"var(--diff-add-ink)"}:E.right===null?{background:"var(--surface)"}:{color:"var(--ink)"},children:[e.jsx("span",{className:"bl-diff-lineno",children:((P=E.right)==null?void 0:P.newLine)??""}),e.jsx("span",{className:"bl-diff-sign",children:((W=E.right)==null?void 0:W.kind)==="add"?"+":""}),e.jsx("span",{className:`bl-diff-code ${f?"whitespace-pre-wrap break-all":"whitespace-pre"}`,children:((I=E.right)==null?void 0:I.text)??""})]})]},s.key)}const{line:t}=s,n=t.kind==="add"?{background:"var(--diff-add-bg)",color:"var(--diff-add-ink)"}:t.kind==="del"?{background:"var(--diff-del-bg)",color:"var(--diff-del-ink)"}:t.kind==="meta"?{color:"var(--muted)"}:{color:"var(--ink)"},d=t.kind==="add"?"+":t.kind==="del"?"-":"";return e.jsxs("div",{className:"bl-diff-unified-row",style:n,children:[e.jsx("span",{className:"bl-diff-lineno",children:t.oldLine??""}),e.jsx("span",{className:"bl-diff-lineno",children:t.newLine??""}),e.jsx("span",{className:"bl-diff-sign",children:d}),e.jsx("span",{className:`bl-diff-code ${f?"whitespace-pre-wrap break-all":"whitespace-pre"}`,children:t.text})]},s.key)}),S.totalHeight-S.offsets[ae.end]>0&&e.jsx("div",{"aria-hidden":"true","data-virtual-spacer":"bottom",style:{height:S.totalHeight-S.offsets[ae.end]}})]}):ue.map((s,t)=>e.jsx("div",{"data-diff-file-body":"true","data-virtualized":"false",className:y==="unified"&&!f?"min-w-max":"w-full",children:s.isBinary?e.jsx("div",{className:"p-6 text-center text-xs",style:{color:"var(--muted)"},children:"二进制文件已变更(不支持文本差异对比)"}):s.hunks.map((n,d)=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1 text-[11px] sticky top-0 z-10",style:{background:"var(--surface)",color:"var(--accent)",borderTop:d>0?"1px solid var(--hair)":void 0,borderBottom:"1px solid var(--hair)"},children:n.header}),y==="split"?e.jsx("div",{"data-diff-mode":"split","data-wrap":f?"true":"false",children:n.splitRows.map((l,v)=>{var g,b,k,P,W,I,E,Ge;return e.jsxs("div",{className:"bl-diff-split-row","data-wrap":f?"true":"false",children:[e.jsxs("div",{className:"bl-diff-cell",style:((g=l.left)==null?void 0:g.kind)==="del"?{background:"var(--diff-del-bg)",color:"var(--diff-del-ink)"}:l.left===null?{background:"var(--surface)"}:{color:"var(--ink)"},children:[e.jsx("span",{className:"bl-diff-lineno",children:((b=l.left)==null?void 0:b.oldLine)??""}),e.jsx("span",{className:"bl-diff-sign",children:((k=l.left)==null?void 0:k.kind)==="del"?"-":" "}),e.jsx("span",{className:`bl-diff-code ${f?"whitespace-pre-wrap break-all":"whitespace-pre"}`,children:((P=l.left)==null?void 0:P.text)??""})]}),e.jsxs("div",{className:"bl-diff-cell bl-diff-cell-right",style:((W=l.right)==null?void 0:W.kind)==="add"?{background:"var(--diff-add-bg)",color:"var(--diff-add-ink)"}:l.right===null?{background:"var(--surface)"}:{color:"var(--ink)"},children:[e.jsx("span",{className:"bl-diff-lineno",children:((I=l.right)==null?void 0:I.newLine)??""}),e.jsx("span",{className:"bl-diff-sign",children:((E=l.right)==null?void 0:E.kind)==="add"?"+":" "}),e.jsx("span",{className:`bl-diff-code ${f?"whitespace-pre-wrap break-all":"whitespace-pre"}`,children:((Ge=l.right)==null?void 0:Ge.text)??""})]})]},v)})}):e.jsx("div",{"data-diff-mode":"unified","data-wrap":f?"true":"false",children:n.lines.map((l,v)=>{const g=l.kind==="add"?{background:"var(--diff-add-bg)",color:"var(--diff-add-ink)"}:l.kind==="del"?{background:"var(--diff-del-bg)",color:"var(--diff-del-ink)"}:l.kind==="meta"?{color:"var(--muted)"}:{color:"var(--ink)"},b=l.kind==="add"?"+":l.kind==="del"?"-":" ";return e.jsxs("div",{className:"bl-diff-unified-row",style:g,children:[e.jsx("span",{className:"bl-diff-lineno",children:l.oldLine??""}),e.jsx("span",{className:"bl-diff-lineno",children:l.newLine??""}),e.jsx("span",{className:"bl-diff-sign",children:b}),e.jsx("span",{className:`bl-diff-code ${f?"whitespace-pre-wrap break-all":"whitespace-pre"}`,children:l.text})]},v)})})]},`${n.header}-${d}`))},`${s.newPath||s.oldPath}-${t}`)):e.jsx("div",{className:"py-12 text-center text-xs",style:{color:"var(--faint)"},children:C.length===0?"两个分支间暂无文件改动":"请在左侧选择改动文件查看代码对比"})})]}),e.jsxs("aside",{className:"bl-codediff-pane bl-codediff-explain flex flex-col min-h-0 overflow-hidden","aria-label":"AI 对应讲解面板",children:[e.jsx("div",{className:"px-3.5 py-2.5 shrink-0 flex items-center justify-between gap-2 flex-wrap",style:{borderBottom:"1px solid var(--hair)"},children:e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-wrap",children:[e.jsx(Re,{size:13,style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-xs font-semibold",style:{color:"var(--ink)"},children:"AI 对应讲解"}),(p==null?void 0:p.cached)&&e.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded-full",style:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair-strong)"},children:"已命中缓存"}),p&&e.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded-full",style:p.aiPowered?{background:"var(--accent-soft)",color:"var(--accent)"}:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair)"},children:p.aiPowered?p.aiModel||p.aiProvider||"AI 讲解":"静态兜底"})]})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-3.5 space-y-3.5 text-xs",children:O&&!p?e.jsx("div",{className:"py-10 text-center",style:{color:"var(--muted)"},children:"正在生成代码改动与影响面讲解…"}):o&&!p?e.jsx("div",{className:"p-3 rounded-lg",style:{background:"var(--diff-del-bg)",color:"var(--diff-del-ink)"},children:o}):p?e.jsxs(e.Fragment,{children:[!p.aiPowered&&p.fallbackReason&&e.jsxs("div",{role:"status",className:"p-2.5 rounded-lg text-[11.5px] leading-relaxed flex items-center justify-between gap-2 flex-wrap",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)",color:"var(--muted)"},children:[e.jsx("span",{className:"min-w-0 flex-1",children:p.fallbackReason}),e.jsx("button",{type:"button",onClick:()=>$e.getState().setSettingsOpen(!0,"ai"),className:"bl-card-action shrink-0 font-medium",style:{color:"var(--accent)"},children:"去配置 AI →"})]}),D&&e.jsxs("section",{"data-active-file-explain":D.path,className:"bl-explain-card space-y-2","data-active":"true",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"caps",style:{color:"var(--accent)"},children:"当前文件对应讲解"}),e.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:Ce(D.category)})]}),e.jsx("div",{className:"mono text-[11px] font-semibold break-all",style:{color:"var(--ink)"},children:D.path}),e.jsx("p",{className:"leading-relaxed",style:{color:"var(--ink)"},children:D.summary}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"p-2 rounded-md text-[11.5px] leading-relaxed",style:{background:"var(--diff-del-bg)"},children:[e.jsx("div",{className:"mono text-[10px] font-semibold mb-0.5",style:{color:"var(--diff-del-ink)"},children:"改前逻辑"}),e.jsx("div",{style:{color:"var(--ink)"},children:D.beforeLogic})]}),e.jsxs("div",{className:"p-2 rounded-md text-[11.5px] leading-relaxed",style:{background:"var(--diff-add-bg)"},children:[e.jsx("div",{className:"mono text-[10px] font-semibold mb-0.5",style:{color:"var(--diff-add-ink)"},children:"现处理逻辑"}),e.jsx("div",{style:{color:"var(--ink)"},children:D.afterLogic})]})]}),D.impact&&e.jsxs("div",{className:"text-[11.5px] leading-relaxed",children:[e.jsx("span",{className:"font-semibold",style:{color:"var(--ink)"},children:"影响面:"}),e.jsx("span",{style:{color:"var(--muted)"},children:D.impact})]}),D.reviewPoints.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"caps",children:"审查要点"}),e.jsx("ul",{className:"space-y-1 pl-4 list-disc text-[11.5px] leading-relaxed",style:{color:"var(--ink)"},children:D.reviewPoints.map((s,t)=>e.jsx("li",{children:s},t))})]})]}),e.jsxs("section",{className:"bl-explain-card space-y-1.5",children:[e.jsx("div",{className:"caps",children:"全局改动概述"}),e.jsx("p",{className:"leading-relaxed",style:{color:"var(--ink)"},children:p.overview})]}),p.contractChanges.length>0&&e.jsxs("section",{className:"bl-explain-card space-y-1.5",children:[e.jsx("div",{className:"caps",children:"接口与契约变化"}),e.jsx("ul",{className:"space-y-1 pl-4 list-disc text-[11.5px] leading-relaxed",style:{color:"var(--ink)"},children:p.contractChanges.map((s,t)=>e.jsx("li",{children:s},t))})]}),p.risks.length>0&&e.jsxs("section",{className:"bl-explain-card space-y-1.5",children:[e.jsx("div",{className:"caps",style:{color:"var(--redline, var(--accent))"},children:"潜在风险"}),e.jsx("ul",{className:"space-y-1 pl-4 list-disc text-[11.5px] leading-relaxed",style:{color:"var(--ink)"},children:p.risks.map((s,t)=>e.jsx("li",{children:s},t))})]}),p.files.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("div",{className:"caps px-0.5",children:["逐文件讲解索引 (",p.files.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:p.files.map(s=>{const t=s.path===j;return e.jsxs("button",{type:"button","data-explain-index":s.path,"data-active":t?"true":void 0,onClick:()=>Pe(s.path),className:"bl-explain-card w-full text-left space-y-1 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"mono text-[11px] truncate font-medium",style:{color:t?"var(--accent)":"var(--ink)"},children:s.path}),e.jsx("span",{className:"mono text-[10px] shrink-0",style:{color:"var(--faint)"},children:Ce(s.category)})]}),e.jsx("div",{className:"text-[11px] line-clamp-2",style:{color:"var(--muted)"},children:s.summary})]},s.path)})})]})]}):null})]})]})]})};export{Hs as CodeDiffStage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as f,j as t}from"./vendor-react-CIotE-6Q.js";import{L as v}from"./LiquidSelect-BcHivJrw.js";import{s as R}from"./vendor-icons-BeN0on9X.js";const h=[{id:"new",label:"独立新会话",hint:"每次新建干净会话,不继承外部历史对话上下文。"},{id:"fork",label:"分叉继承",badge:"推荐",hint:"继承选定历史对话上下文,在隔离工作区创建独立分支子会话(thread/fork),绝不污染原对话。"},{id:"resume",label:"直接续接",hint:"直接续写回选定的原 Codex 对话(thread/resume;请确保原对话当前未在运行,避免并发冲突)。"}];function z(s){const r=new Date(s);return Number.isNaN(r.getTime())?"":r.toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1})}const B=({data:s,loading:r,error:u,projectId:N,sessionMode:o,sessionId:i,sessionTitle:d,onProjectIdChange:C,onSessionModeChange:y,onSelectSession:m,onRefresh:w,compact:x=!1,isRace:k=!1})=>{var j;const n=s&&s.matchedProjects.length>0?s.matchedProjects.map(e=>e.name).join(" / "):"",c=(s==null?void 0:s.sessions)??[],b=(s==null?void 0:s.allProjects)??[],g=i?c.some(e=>e.id===i):!0,$=((j=h.find(e=>e.id===o))==null?void 0:j.hint)??h[0].hint,L=k&&o==="resume",S=f.useMemo(()=>[{value:"",label:`自动匹配当前仓库${n?`(${n})`:""}`},...b.map(e=>({value:e.id,label:`${e.name}${e.matchedCurrentRepo?" · 当前仓库":""}`}))],[n,b]),O=f.useMemo(()=>{const a=[{value:"",label:r?"正在读取本地 Codex 对话…":c.length===0?"暂无匹配的历史对话(可切换项目或手动输入 ID)":"请选择要关联的 Codex 历史对话…"}];i&&!g&&a.push({value:i,label:d?`${d} (${i.slice(0,8)})`:i});for(const l of c){const p=z(l.updatedAt),D=l.gitBranch?` [${l.gitBranch}]`:"";a.push({value:l.id,label:`${l.title}${D}`,hint:p||void 0})}return a},[r,g,i,d,c]);return t.jsxs("div",{className:x?"p-3 rounded-xl space-y-2.5":"p-3.5 rounded-xl space-y-3",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)"},children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[t.jsx("span",{className:"caps shrink-0",children:"关联 Codex 项目与对话"}),n&&t.jsxs("span",{className:"mono text-[10.5px] px-2 py-0.5 rounded-full truncate max-w-[230px]",style:{background:"var(--accent-soft)",color:"var(--accent)"},title:`已匹配本地 Codex 项目:${n}`,children:["匹配项目:",n]})]}),t.jsx("button",{type:"button",onClick:w,disabled:r,"aria-label":"刷新 Codex 对话列表",title:"重新扫描本地 Codex 项目与对话",className:"opacity-70 hover:opacity-100 p-1 shrink-0 disabled:opacity-40",children:t.jsx(R,{size:13,className:r?"animate-spin":""})})]}),t.jsx("div",{className:"grid grid-cols-3 gap-1.5 items-stretch",role:"group","aria-label":"Codex 会话关联模式",children:h.map(e=>t.jsxs("button",{type:"button",onClick:()=>y(e.id),className:"bl-choice-btn justify-center flex-wrap gap-1 text-xs",style:{minHeight:x?32:34,height:"auto",padding:x?"6px 8px":"7px 10px",lineHeight:1.3},"data-active":o===e.id?"true":void 0,"aria-pressed":o===e.id,title:e.hint,children:[t.jsx("span",{className:"whitespace-nowrap",children:e.label}),e.badge&&t.jsx("span",{className:"mono text-[9.5px] opacity-80 whitespace-nowrap",children:e.badge})]},e.id))}),t.jsx("p",{className:"text-[11px] leading-relaxed",style:{color:"var(--muted)"},children:$}),L&&t.jsx("div",{role:"status","data-race-resume-notice":"true",className:"p-2 rounded-lg text-[11px] leading-relaxed",style:{background:"rgba(217, 119, 6, 0.12)",color:"#b45309",border:"1px solid rgba(217, 119, 6, 0.35)"},children:"多方案赛马并行执行时将自动改为「分叉继承」,为每路方案创建独立子会话,避免并发写乱同一原对话。"}),o!=="new"&&t.jsxs("div",{className:"space-y-2 pt-0.5",children:[t.jsxs("div",{children:[t.jsx("label",{className:"caps block mb-1",children:"Codex 项目范围"}),t.jsx(v,{value:N,options:S,onChange:C,ariaLabel:"关联 Codex 项目",size:"md",fullWidth:!0,maxMenuWidth:460,className:"text-xs"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"caps block mb-1",children:"选择历史对话"}),t.jsx(v,{value:i,options:O,onChange:e=>{const a=c.find(l=>l.id===e);m(e,(a==null?void 0:a.title)||"")},ariaLabel:"关联 Codex 对话",size:"md",fullWidth:!0,disabled:r,maxMenuWidth:460,className:"text-xs"})]}),t.jsx("div",{children:t.jsx("input",{type:"text",value:i,onChange:e=>{const a=e.target.value,l=c.find(p=>p.id===a.trim());m(a,(l==null?void 0:l.title)||"")},"aria-label":"手动输入 Codex 对话 ID",placeholder:"或直接粘贴 Codex 会话 UUID(如 01a21b9e-...)",className:"sheet-input w-full h-7 text-[11px] mono"})})]}),(u||(s==null?void 0:s.warning))&&t.jsx("div",{className:"text-[11px] leading-relaxed",style:{color:"#d97706"},children:u||(s==null?void 0:s.warning)})]})};export{B as C};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeDiffStage-BAkeoFAz.js","./vendor-react-CIotE-6Q.js","./index-CuRBE0Be.js","./vendor-icons-BeN0on9X.js","./index-B76NgI6o.css","./presets-DiVmkZ02.js","./stageCache-nD7q31wP.js","./ResponsiveMatrixStage-IZfS6JC4.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as Je,V as Ye,k as yt,a as Qe,j as tn,b as sn,w as nn,_ as ps}from"./index-CuRBE0Be.js";import{r,j as e,a as ln,R as hs}from"./vendor-react-CIotE-6Q.js";import{L as es}from"./LiquidSelect-BcHivJrw.js";import{N as rn,O as ms,Q as an,F as on,x as xs,U as cn,b as bs,V as dn,y as un,e as Ze,W as fn,Y as pn,X as xt,c as gs,j as hn,C as mn,a as xn,g as bn,s as ts,Z as gn}from"./vendor-icons-BeN0on9X.js";import{R as yn}from"./RouteBar-CbnzrFM4.js";import{f as vn,s as jn}from"./pickedElement-DWJDcr9q.js";const wn=[{id:"split",label:"并排"},{id:"slider",label:"卷帘"},{id:"blend",label:"差异"},{id:"onion",label:"叠图"},{id:"single",label:"独览"}],kn=({branches:t,baseRef:s,targetRef:l,compareSurface:i="visual",changeSummary:d,onCompareSurfaceChange:u,viewMode:o,opacity:m,holdingOriginal:n,picking:c,pickedCount:a,canPick:f,onViewModeChange:g,onOpacityChange:x,onHoldingOriginalChange:h,onTogglePicking:b,onBaseChange:j,onTargetChange:S,onSwap:w,onReload:A,onGoAnnotate:M,onOpenPrDraft:R,onBackToTree:y})=>{const $=i==="visual",p=i==="code",N=i==="matrix",C=(d==null?void 0:d.backendFiles)??0,_=r.useMemo(()=>{const k=[];s&&!t.some(E=>E.ref===s)&&k.push({value:s,label:`历史提交 ${s.slice(0,7)}`});for(const E of t)k.push({value:E.ref,label:E.label});return k},[t,s]),L=r.useMemo(()=>{const k=[];l&&!t.some(E=>E.ref===l)&&k.push({value:l,label:`历史提交 ${l.slice(0,7)}`});for(const E of t)k.push({value:E.ref,label:E.label});return k},[t,l]);return e.jsxs("div",{className:"bl-subbar bl-compare-toolbar py-1.5 px-4 shrink-0 flex flex-col gap-1.5 z-10",children:[e.jsxs("div",{"data-has-surface-tabs":u?"true":void 0,className:"bl-compare-toolbar-primary flex items-center justify-between gap-x-3 gap-y-1.5 flex-wrap min-w-0",children:[e.jsxs("div",{className:"bl-compare-refs flex items-center gap-2 text-[13px] flex-wrap min-w-0 max-w-full",children:[e.jsx("button",{type:"button",onClick:y,className:"hover:underline underline-offset-4 mr-1 font-medium shrink-0",style:{color:"var(--ink)"},children:"← 分支树"}),e.jsx("span",{style:{color:"var(--hair-strong)"},children:"|"}),e.jsx("span",{className:"caps shrink-0",children:"A 原版"}),e.jsx(es,{value:s||"",options:_,onChange:j,ariaLabel:"选择原版分支",placeholder:"选择原版",size:"sm",minMenuWidth:184,className:"bl-compare-ref-select text-[12.5px] font-medium max-w-[148px] min-w-0"}),e.jsx("button",{type:"button",onClick:w,title:"互换原版与对比版",className:"mono px-1 hover:opacity-100 opacity-65 shrink-0",children:"⇄"}),e.jsx("span",{className:"caps shrink-0",style:{color:"var(--accent)"},children:"B 对比"}),e.jsx(es,{value:l||"",options:L,onChange:S,ariaLabel:"选择对比分支",placeholder:"选择分支",size:"sm",minMenuWidth:184,className:"bl-compare-ref-select text-[12.5px] font-medium max-w-[148px] min-w-0"})]}),u&&e.jsxs("div",{role:"tablist","aria-label":"对比舞台模式",className:"bl-surface-tabs inline-flex items-center gap-1 flex-wrap max-w-full",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":$,"data-active":$?"true":void 0,onClick:()=>u("visual"),className:"bl-surface-tab",children:[e.jsx(rn,{size:13}),e.jsx("span",{children:"界面对比"})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":p,"data-active":p?"true":void 0,onClick:()=>u("code"),className:"bl-surface-tab",children:[e.jsx(ms,{size:13}),e.jsx("span",{children:C>0?`代码对比 + AI 讲解(含 ${C} 个后端文件)`:"代码对比 + AI 讲解"})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":N,"data-active":N?"true":void 0,onClick:()=>u("matrix"),className:"bl-surface-tab",children:[e.jsx(an,{size:13}),e.jsx("span",{children:"响应式矩阵"})]})]}),R&&e.jsxs("button",{type:"button",onClick:R,disabled:!s||!l,className:"bl-compare-pr-btn sheet-btn text-xs py-1 px-2.5 shrink-0 disabled:opacity-35",title:"基于当前对比分支生成 PR 描述草稿",children:[e.jsx(on,{size:12}),e.jsx("span",{children:"生成 PR 描述"})]})]}),$&&e.jsxs("div",{className:"bl-compare-toolbar-secondary min-w-0 pt-1.5",children:[e.jsx("div",{className:"bl-compare-secondary-left flex items-center min-w-0",children:o==="onion"&&e.jsxs("label",{"data-testid":"compare-onion-opacity",className:"bl-compare-onion-opacity flex items-center gap-1.5 text-xs shrink-0",style:{color:"var(--muted)"},children:[e.jsx("span",{children:"透叠"}),e.jsx("input",{type:"range",min:0,max:100,value:m,onChange:k=>x(Number(k.target.value)),className:"w-16",style:{accentColor:"var(--accent)"}}),e.jsxs("span",{className:"mono w-8 text-right",children:[m,"%"]})]})}),e.jsx("div",{className:"bl-compare-viewmodes flex items-center gap-3 shrink-0",children:wn.map(k=>e.jsx("button",{type:"button",onClick:()=>g(k.id),className:"text-[13px] pb-0.5 transition-colors whitespace-nowrap",style:{color:o===k.id?"var(--ink)":"var(--muted)",fontWeight:o===k.id?600:480,borderBottom:o===k.id?"2px solid var(--accent)":"2px solid transparent"},children:k.label},k.id))}),e.jsxs("div",{className:"bl-compare-actions flex items-center gap-2.5 text-[12.5px] font-medium flex-wrap min-w-0",children:[e.jsx("button",{type:"button",onMouseDown:()=>h(!0),onMouseUp:()=>h(!1),onMouseLeave:()=>h(!1),className:"text-[12px] px-2 py-0.5 rounded-full whitespace-nowrap transition-colors",style:{color:n?"var(--accent)":"var(--muted)",background:n?"var(--accent-soft)":"transparent",border:`1px solid ${n?"var(--accent)":"var(--hair-strong)"}`},title:"按住鼠标或空格键,瞬间闪看原版",children:n?"■ 正在看原版":"按住 Space 闪看原版"}),e.jsxs("button",{type:"button",onClick:b,disabled:!f&&!c,"aria-pressed":c,"data-active":c?"true":void 0,className:"bl-picker-toggle disabled:opacity-35",title:c?"点击或按 Esc 退出点选元素模式":"开启点选模式,点击预览页面元素定位源码",children:[e.jsx(xs,{size:13}),e.jsx("span",{children:c?"点选中":"点选元素"}),a>0&&e.jsx("span",{className:"mono text-[10.5px] px-1.5 rounded-full",style:{background:c?"rgba(255,255,255,0.22)":"var(--accent-soft)",color:c?"#ffffff":"var(--accent)"},children:a})]}),e.jsx("button",{type:"button",onClick:A,title:"刷新预览画面",className:"mono opacity-65 hover:opacity-100",children:"↻"}),e.jsx("button",{type:"button",onClick:M,disabled:!s||!l,className:"sheet-link disabled:opacity-35",style:{color:"var(--accent)",borderColor:"var(--accent)"},children:"红框批注 →"})]})]})]})},Nn=/:([\w-]+)(?:\([^)]*\))?[?*+]?|\[\[?(?:\.\.\.)?([\w-]+)\]\]?|(\*)(?=\/|$)/g;function ss(t,s){return t.replace(Nn,(l,i,d,u)=>{const m=(s[i??d??u]||"1").trim()||"1";return l.includes("...")||/[*+]$/.test(l)?m.split("/").map(encodeURIComponent).join("/"):encodeURIComponent(m)})}const Sn=({route:t,allRoutes:s,routeParams:l,onSelectRoute:i,onSaveRouteParams:d})=>{const[u,o]=r.useState(!1),[m,n]=r.useState(""),[c,a]=r.useState(null),[f,g]=r.useState({}),[x,h]=r.useState(""),[b,j]=r.useState(!1),S=r.useRef(null);r.useEffect(()=>{if(!u)return;const p=C=>{S.current&&!S.current.contains(C.target)&&o(!1)},N=C=>{C.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",p),window.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",p),window.removeEventListener("keydown",N)}},[u]);const{affectedRoutes:w,otherRoutes:A}=r.useMemo(()=>{const p=m.trim().toLowerCase(),N=p?s.filter(C=>[C.route,C.resolvedRoute,C.label,C.componentName,C.sourceFile].filter(Boolean).some(_=>_.toLowerCase().includes(p))):s;return{affectedRoutes:N.filter(C=>C.affected),otherRoutes:N.filter(C=>!C.affected)}},[s,m]);if(s.length===0)return null;const M=p=>`${p.sourceFile}::${p.route}`,R=p=>{var C;const N=M(p);if(c===N){a(null);return}if(a(N),p.paramNames&&p.paramNames.length>0){const _={};for(const L of p.paramNames)_[L]=(l==null?void 0:l[L])||((C=p.sampleParams)==null?void 0:C[L])||"1";g(_)}else h((l==null?void 0:l[p.route])||p.resolvedRoute)},y=async(p,N)=>{if(N.preventDefault(),!b){j(!0);try{let C,_;if(p.paramNames&&p.paramNames.length>0)C=Object.fromEntries(p.paramNames.map(L=>[L,(f[L]||"").trim()||"1"])),_=ss(p.route,C);else{const L=x.trim();_=L.startsWith("/")?L:`/${L}`,C={[p.route]:_}}await(d==null?void 0:d(C)),i(_),a(null),o(!1)}finally{j(!1)}}},$=p=>{const N=M(p),C=t===p.resolvedRoute||t===p.route,_=c===N,L=p.dependencyDepth===0?"直接改动":typeof p.dependencyDepth=="number"&&p.dependencyDepth>0?`依赖深度 ${p.dependencyDepth}`:null;return e.jsxs("div",{className:"bl-route-catalog-item","data-active":C?"true":void 0,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{i(p.resolvedRoute),o(!1)},className:"flex-1 min-w-0 text-left space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"font-medium text-[12px]",style:{color:"var(--ink)"},children:p.label}),e.jsx("span",{className:"mono text-[11px]",style:{color:C?"var(--accent)":"var(--muted)"},children:p.resolvedRoute}),p.isParameterized&&e.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:"参数化"}),L&&e.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--redline-soft, var(--accent-soft))",color:"var(--redline, var(--accent))"},children:L}),p.affected&&p.changedFiles.length>0&&e.jsxs("span",{className:"mono text-[10px]",style:{color:"var(--muted)"},children:[p.changedFiles.length," 个改动文件"]})]}),e.jsxs("div",{className:"mono text-[10.5px] truncate",style:{color:"var(--faint)"},children:[p.isParameterized?`${p.route} · `:"",p.sourceFile]})]}),p.isParameterized&&e.jsxs("button",{type:"button",onClick:()=>R(p),className:"bl-card-action inline-flex items-center gap-1 shrink-0 text-[11px]",title:"编辑路由参数并保存至项目配置",children:[e.jsx(un,{size:11}),e.jsx("span",{children:_?"收起":"配置参数"})]})]}),_&&e.jsxs("form",{onSubmit:k=>void y(p,k),className:"mt-2 pt-2 space-y-2",style:{borderTop:"1px solid var(--hair)"},children:[p.paramNames&&p.paramNames.length>0?e.jsx("div",{className:"grid grid-cols-2 gap-2",children:p.paramNames.map(k=>e.jsxs("label",{className:"block",children:[e.jsxs("span",{className:"mono text-[10px] block mb-0.5",style:{color:"var(--muted)"},children:[":",k]}),e.jsx("input",{type:"text","aria-label":`参数 ${k}`,value:f[k]??"",onChange:E=>g(I=>({...I,[k]:E.target.value})),className:"sheet-input w-full h-7 text-[11px] mono"})]},k))}):e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mono text-[10px] block mb-0.5",style:{color:"var(--muted)"},children:"示例路径"}),e.jsx("input",{type:"text","aria-label":`示例路径 ${p.route}`,value:x,onChange:k=>h(k.target.value),className:"sheet-input w-full h-7 text-[11px] mono"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"mono text-[10.5px] truncate",style:{color:"var(--muted)"},children:["目标:",p.paramNames&&p.paramNames.length>0?ss(p.route,f):x||p.resolvedRoute]}),e.jsx("button",{type:"submit",disabled:b,className:"sheet-btn sheet-btn-primary text-[11px] py-0.5 px-2.5 shrink-0",children:b?"保存中…":"保存并跳转"})]})]})]},N)};return e.jsxs("div",{ref:S,className:"relative shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>o(p=>!p),"aria-expanded":u,"aria-haspopup":"dialog",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[12px] transition-colors",style:{background:u?"var(--accent-soft)":"transparent",color:u?"var(--accent)":"var(--ink)",border:`1px solid ${u?"var(--accent)":"var(--hair-strong)"}`,fontWeight:520},title:"查看并搜索全仓前端页面路由目录",children:[e.jsx(cn,{size:12}),e.jsxs("span",{children:["全仓页面目录 (",s.length,")"]}),e.jsx(bs,{size:12})]}),u&&e.jsxs("div",{role:"dialog","aria-label":"全仓页面目录",className:"bl-route-catalog absolute left-0 top-full mt-1.5 w-[440px] max-w-[90vw] z-40 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"p-2.5 flex items-center gap-2 shrink-0",style:{borderBottom:"1px solid var(--hair)"},children:[e.jsx(dn,{size:13,style:{color:"var(--muted)"}}),e.jsx("input",{type:"text",value:m,onChange:p=>n(p.target.value),placeholder:"搜索路由、页面名或源码文件…","aria-label":"搜索全仓页面",autoFocus:!0,className:"flex-1 bg-transparent outline-none text-xs",style:{color:"var(--ink)"}}),m&&e.jsx("button",{type:"button",onClick:()=>n(""),className:"text-[11px] hover:underline",style:{color:"var(--muted)"},children:"清空"})]}),e.jsxs("div",{className:"max-h-[360px] overflow-y-auto p-2 space-y-3",children:[w.length>0&&e.jsxs("section",{className:"space-y-1",children:[e.jsxs("div",{className:"caps px-2 py-0.5",children:["本次改动波及页面 (",w.length,")"]}),w.map($)]}),A.length>0&&e.jsxs("section",{className:"space-y-1",children:[e.jsxs("div",{className:"caps px-2 py-0.5",children:["全仓前端页面 (",A.length,")"]}),A.map($)]}),w.length===0&&A.length===0&&e.jsx("div",{className:"py-6 text-center text-xs",style:{color:"var(--muted)"},children:"未匹配到页面路由"})]})]})]})},Mn=({route:t,onRouteChange:s,compareTargets:l,allRoutes:i=[],routeParams:d,onSaveRouteParams:u,mockAuthEnabled:o=!1,mockAuthBusy:m=!1,onToggleMockAuth:n,canAutoLogin:c=!1,autoLoginBusy:a=!1,onAutoLogin:f,liveDiffs:g,activeDiffIdx:x,baseUrl:h,targetUrl:b,spotlightEnabled:j,aiExplainMode:S=!1,syncEnabled:w,hasSavedSession:A,isOnLoginScreen:M,onFocusDiffSpot:R,onToggleSpotlight:y,onToggleAiExplain:$,onTriggerRescan:p,onToggleSync:N,onClearSession:C})=>{var _,L;return e.jsxs("div",{className:"bl-live-diff-bar px-4 py-1.5 shrink-0 flex items-center justify-between gap-2.5 flex-wrap text-xs z-20",style:{borderBottom:"1px solid var(--hair)",background:"var(--surface)"},children:[e.jsxs("div",{className:"flex items-center gap-2.5 flex-wrap min-w-0 max-w-full",children:[e.jsx(yn,{route:t,onRouteApply:s}),(l.length>0||i.length>0)&&e.jsx("span",{className:"h-4 w-px shrink-0",style:{background:"var(--hair-strong)"},"aria-hidden":"true"}),l.length>0&&e.jsx("span",{className:"caps shrink-0",children:"改动直达"}),l.slice(0,5).map(k=>{const E=t===k.route;return e.jsxs("button",{type:"button",onClick:()=>s(k.route),title:`${k.route} · ${k.reason}`,className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full transition-colors text-[12px]",style:{background:E?"var(--accent-soft)":"transparent",color:E?"var(--accent)":"var(--ink)",border:`1px solid ${E?"var(--accent)":"var(--hair-strong)"}`,fontWeight:E?600:480},children:[e.jsx("span",{children:k.label}),e.jsx("span",{className:"mono text-[10.5px] opacity-70",children:k.route}),k.noLogin&&/\/design-review\//i.test(k.route)&&e.jsx("span",{className:"text-[10px] px-1 rounded",style:{background:"var(--accent)",color:"#fff"},children:"免登录"})]},k.route)}),e.jsx(Sn,{route:t,allRoutes:i,routeParams:d,onSelectRoute:s,onSaveRouteParams:u})]}),e.jsxs("div",{className:"flex items-center gap-3 min-w-0 max-w-full flex-wrap",children:[h&&b&&e.jsx("div",{className:"flex items-center gap-1.5",children:g.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"mono font-semibold text-[11.5px] px-2 py-0.5 rounded-full",style:{background:"var(--redline-soft, var(--accent-soft))",color:"var(--redline, var(--accent))"},title:(_=g[x])==null?void 0:_.label,children:["✦ 发现 ",g.length," 处页面差异"]}),e.jsx("button",{type:"button",onClick:()=>R(x-1),className:"bl-card-action mono",title:"跳到上一处差异",children:"↑"}),e.jsxs("button",{type:"button",onClick:()=>R(x+1),className:"bl-card-action font-medium",style:{color:"var(--redline, var(--accent))"},title:((L=g[x])==null?void 0:L.label)||"定位到下一处差异",children:["定位差异 (",x+1,"/",g.length,") ↓"]}),$&&e.jsxs("button",{type:"button",onClick:$,"data-testid":"live-diff-ai-explain-btn","aria-pressed":S,"data-active":S?"true":void 0,className:"bl-ai-explain-toggle",title:S?"AI 讲解已开启:点击预览页中的任意红框查看差异解读(再次点击退出)":"开启红框 AI 讲解模式:直接点击页面上的差异红框查看详细解读",children:[e.jsx(Ze,{size:11.5,className:"shrink-0"}),e.jsx("span",{children:S?"AI 讲解 · 点红框":"AI 讲解"})]}),e.jsx("button",{type:"button",onClick:y,className:"hover:underline underline-offset-4",style:{color:"var(--muted)"},children:j?"高亮:开":"高亮:关"})]}):e.jsx("button",{type:"button",onClick:p,className:"hover:underline underline-offset-4",style:{color:"var(--muted)"},title:"重新扫描当前双端页面找出差异元素",children:"↻ 扫描页面差异"})}),e.jsxs("button",{type:"button",onClick:N,className:"hover:underline underline-offset-4",style:{color:w?"var(--accent)":"var(--muted)",fontWeight:w?600:450},title:"开启后,在一侧滚动或切换页面将自动同步到另一侧",children:["同步联动:",w?"开":"关"]}),(n||o)&&e.jsxs("button",{type:"button",onClick:n,disabled:m||!n,"aria-pressed":o,"data-active":o?"true":void 0,className:"bl-mock-auth-btn disabled:opacity-50",title:o?"Mock 免登模式已开启(点击关闭并立即刷新预览)":"开启 Mock 免登模式(无需重启预览实例)",children:[e.jsx(fn,{size:12}),e.jsx("span",{children:o?"Mock 免登模式":"Mock 免登"})]}),A?e.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"#15803d"},children:[e.jsx("span",{children:"✓ 已同步登录态"}),e.jsx("button",{type:"button",onClick:C,className:"hover:underline underline-offset-4",style:{color:"var(--faint)"},children:"清除"})]}):e.jsxs(e.Fragment,{children:[c&&f&&e.jsxs("button",{type:"button",onClick:f,disabled:a,className:"bl-card-action inline-flex items-center gap-1 font-medium disabled:opacity-50",style:{color:"var(--accent)"},title:"调用项目配置的测试账号接口自动登录并同步会话",children:[e.jsx(pn,{size:11}),e.jsx("span",{children:a?"登录中…":"一键测试登录"})]}),M&&e.jsx("span",{style:{color:"var(--muted)"},children:"一侧登录后另一侧自动同步免登"})]})]})]})},Cn=({picking:t,items:s,onStopPicking:l,onRemoveItem:i,onClearAll:d,onSendToCodex:u})=>{const o=Je(h=>h.pushToast),[m,n]=r.useState(null),[c,a]=r.useState(null);if(r.useEffect(()=>{c&&!s.some(h=>h.id===c)&&a(null)},[c,s]),!t&&s.length===0)return null;const f=s.some(h=>h.sourceVerifying),g=c?s.find(h=>h.id===c)??null:null,x=async(h,b)=>{if(!navigator.clipboard||typeof navigator.clipboard.writeText!="function"){o({tone:"warning",title:"无法自动复制源码位置",detail:`当前环境不支持剪贴板写入,请手动复制:${b}`,copyCommand:b,durationMs:4500});return}try{await navigator.clipboard.writeText(b),n(h),o({tone:"success",title:"已复制源码位置",detail:b,durationMs:2600}),window.setTimeout(()=>{n(j=>j===h?null:j)},1800)}catch{o({tone:"warning",title:"复制源码位置失败",detail:`请手动复制:${b}`,copyCommand:b,durationMs:4500})}};return e.jsxs("div",{className:"bl-picker-shell shrink-0 z-10","data-picking":t?"true":void 0,children:[t&&e.jsxs("div",{className:"bl-picker-banner px-4 py-1 flex items-center justify-between gap-2 flex-wrap text-[11.5px]",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"bl-picker-dot","aria-hidden":"true"}),e.jsx(xs,{size:12,style:{color:"var(--accent)"},className:"shrink-0"}),e.jsx("span",{className:"font-semibold shrink-0",style:{color:"var(--ink)"},children:"点选模式已开启"}),e.jsx("span",{className:"truncate",style:{color:"var(--muted)"},children:"点击预览元素即可加入下方标签条(支持多选,Esc 退出)"})]}),e.jsxs("button",{type:"button",onClick:l,className:"bl-card-action inline-flex items-center gap-1 shrink-0",children:[e.jsx(xt,{size:11}),e.jsx("span",{children:"退出点选 (Esc)"})]})]}),s.length>0&&e.jsxs("div",{className:"bl-picker-tray px-4 py-1.5 space-y-1.5","data-testid":"picked-elements-tray",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{className:"caps text-[10.5px]",children:"已点选"}),e.jsx("span",{className:"mono text-[10.5px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-soft)",color:"var(--accent)"},children:s.length})]}),e.jsx("div",{className:"bl-picker-strip flex-1",children:s.map((h,b)=>{var M;const{element:j}=h,S=j.source?vn(j.source):null,w=m===h.id,A=c===h.id;return e.jsxs("article",{className:"bl-picker-card shrink-0 text-[11px]","data-expanded":A?"true":void 0,children:[e.jsxs("button",{type:"button","aria-expanded":A,onClick:()=>a(A?null:h.id),className:"inline-flex items-center gap-1 min-w-0 hover:opacity-85",title:`点击${A?"收起":"展开"}样式与选择器详情(${h.slot==="a"?"A 原版":"B 对比"} · ${j.domPath||j.selector})`,children:[A?e.jsx(bs,{size:11,className:"shrink-0 opacity-70"}):e.jsx(gs,{size:11,className:"shrink-0 opacity-70"}),e.jsxs("span",{className:"mono text-[10px] font-semibold",style:{color:"var(--accent)"},children:["#",b+1]}),e.jsxs("span",{className:"mono font-semibold",style:{color:"var(--ink)"},children:["<",j.tag,">"]}),e.jsx("span",{className:"mono truncate max-w-[130px]",style:{color:"var(--muted)"},children:(M=j.source)!=null&&M.component?`${j.source.component} · ${j.selector}`:j.selector})]}),h.sourceVerifying?e.jsx("span",{className:"text-[10.5px] shrink-0",style:{color:"var(--muted)"},children:"校验中…"}):S?e.jsxs("button",{type:"button",onClick:()=>void x(h.id,S),className:"bl-picker-source-btn mono text-[10.5px] inline-flex items-center gap-1 max-w-[180px]",title:`点击复制源码位置:${S}`,children:[e.jsx(hn,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:S}),w?e.jsx(mn,{size:10,className:"shrink-0"}):e.jsx(xn,{size:10,className:"shrink-0 opacity-70"})]}):e.jsx("span",{className:"text-[10.5px] truncate max-w-[120px]",style:{color:"var(--faint)"},title:"未能定位源码,将以选择器描述",children:"未能定位源码,将以选择器描述"}),s.length>1&&e.jsx("button",{type:"button",onClick:()=>u([h]),disabled:!!h.sourceVerifying,className:"text-[10.5px] shrink-0 hover:underline underline-offset-2 disabled:opacity-45 disabled:no-underline",style:{color:"var(--accent)"},title:h.sourceVerifying?"正在校验该元素源码路径,请稍候":"仅携带这一项元素打开任务派发弹窗",children:h.sourceVerifying?"校验中…":"单独派发"}),e.jsx("button",{type:"button",onClick:()=>i(h.id),"aria-label":`移除点选元素 #${b+1}`,title:"移除此元素",className:"p-0.5 rounded-full opacity-60 hover:opacity-100 transition-opacity shrink-0",style:{color:"var(--muted)"},children:e.jsx(xt,{size:11})})]},h.id)})}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("button",{type:"button",onClick:d,className:"sheet-btn text-[11.5px]",style:{height:26,padding:"0 9px"},title:"清空所有已点选元素",children:[e.jsx(bn,{size:11}),e.jsx("span",{children:"清空"})]}),e.jsxs("button",{type:"button",onClick:()=>u(s),disabled:f,className:"sheet-btn sheet-btn-primary text-[11.5px] disabled:opacity-45",style:{height:26,padding:"0 10px"},title:f?"正在完成服务端源码路径校验,请稍候":"携带全部已点选元素打开任务派发弹窗",children:[e.jsx(Ze,{size:11}),e.jsx("span",{children:f?"校验中…":"交给 Codex"})]})]})]}),g&&e.jsxs("div",{"data-testid":"picked-element-detail",className:"bl-picker-detail-drawer px-3 py-2 flex items-center justify-between gap-3 flex-wrap text-[11px]",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[e.jsxs("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded shrink-0",style:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair)"},children:[g.slot==="a"?"A 原版":"B 对比"," · ",g.ref]}),e.jsx("span",{className:"mono truncate max-w-[360px]",style:{color:"var(--ink)"},title:g.element.domPath||g.element.selector,children:g.element.domPath||g.element.selector}),g.element.text&&e.jsxs("span",{className:"truncate max-w-[200px]",style:{color:"var(--muted)"},title:g.element.text,children:["“",g.element.text,"”"]})]}),e.jsx("div",{className:"flex items-center gap-1 flex-wrap min-w-0",children:Object.entries(g.element.styles||{}).slice(0,6).map(([h,b])=>e.jsxs("span",{className:"bl-picker-style-chip mono",title:`${h}: ${b}`,children:[h,": ",b]},h))})]})]})]})},T=12,ve=12,ns=368,ls=380,An=480,Ln=200,En={added:{label:"新增",tone:"add"},removed:{label:"移除",tone:"del"},changed:{label:"内容调整",tone:"accent"},style:{label:"样式调整",tone:"accent"}};function Le(t){return(t??"").replace(/\s+/g," ").trim()}function rs(t){const s=Le(t).toLowerCase();return!s||s==="transparent"||s==="none"||s==="initial"||s==="inherit"||s==="currentcolor"||/^rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0(?:\.0+)?\s*\)$/.test(s)||/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*0(?:\.0+)?\s*\)$/.test(s)?!1:/^(?:#[0-9a-f]{3,8}|rgba?\([^)]+\)|hsla?\([^)]+\)|[a-z]{3,20})$/i.test(s)}function Bn(t){var l;return(((l=Le(t).split(",")[0])==null?void 0:l.replace(/^["']|["']$/g,"").trim())??"").slice(0,24)}function Rn(t,s){const l=[],i=[],d=[],u=[],o=[{key:"bg",label:"背景"},{key:"color",label:"文字"},{key:"borderColor",label:"边框"}];for(const n of o){const c=Le(t==null?void 0:t[n.key]),a=Le(s==null?void 0:s[n.key]);c!==a&&(rs(c)&&l.push({key:n.key,label:n.label,value:c}),rs(a)&&i.push({key:n.key,label:n.label,value:a}))}const m=[{key:"fontFamily",label:"字体",format:Bn},{key:"fontSize",label:"字号"},{key:"fontWeight",label:"字重"},{key:"borderRadius",label:"圆角"}];for(const n of m){const c=Le(t==null?void 0:t[n.key]),a=Le(s==null?void 0:s[n.key]);if(c===a)continue;const f=n.format?n.format(c):c,g=n.format?n.format(a):a;f&&d.push({key:n.key,label:n.label,value:f}),g&&u.push({key:n.key,label:n.label,value:g})}return{swatchesA:l,swatchesB:i,badgesA:d,badgesB:u}}function Ge(t,s,l){return l<s?s:Math.max(s,Math.min(l,t))}function as(t,s,l,i,d){const u=i>0?i:1280,o=d>0?d:800,m=Math.max(120,Math.floor(o-T*2)),n=Math.min(An,m),c=Math.min(Ln,m),a=Math.min(s,Math.max(240,u-T*2)),f=Math.min(l,n),g=t.left+t.width,x=t.top+t.height;if(u-g-ve-T>=a){const M=Math.round(Ge(t.top-12,T,o-f-T)),R=Math.max(c,Math.min(n,Math.floor(o-T-M))),y=Math.round(Math.max(T,Math.min(M,o-T-R)));return{left:Math.round(g+ve),top:y,maxHeight:Math.min(n,Math.max(120,Math.floor(o-T-y))),placement:"right"}}if(t.left-ve-T>=a){const M=Math.round(Ge(t.top-12,T,o-f-T)),R=Math.max(c,Math.min(n,Math.floor(o-T-M))),y=Math.round(Math.max(T,Math.min(M,o-T-R)));return{left:Math.round(t.left-ve-a),top:y,maxHeight:Math.min(n,Math.max(120,Math.floor(o-T-y))),placement:"left"}}const h=Math.floor(o-x-ve-T),b=Math.floor(t.top-ve-T),j=Math.min(f,c),S=Math.round(Ge(t.left,T,u-a-T)),w=()=>{const M=Math.min(n,Math.max(c,b)),R=Math.min(f,M),y=Math.round(Ge(t.top-ve-R,T,o-T-M)),$=Math.min(n,Math.max(120,Math.min(M,Math.floor(o-T-y))));return{left:S,top:y,maxHeight:$,placement:"top"}},A=()=>{const M=Math.round(x+ve),R=o-T-M<c?Math.max(T,Math.round(o-T-c)):Math.max(T,M),y=Math.min(n,Math.max(120,Math.floor(o-T-R)));return{left:S,top:R,maxHeight:y,placement:"bottom"}};return h>=j?h<f&&b>=j&&b>h+40?w():A():b>=j?w():{left:Math.round(Math.max(T,u-a-T)),top:T,maxHeight:n,placement:"corner"}}const $n=({activeExplain:t,baseLabel:s,targetLabel:l,totalDiffs:i,currentIdx:d,onClose:u,onNavigate:o,onRetry:m,onOpenCodeDiff:n})=>{const c=r.useRef(null),a=r.useRef(null),[f,g]=r.useState(null),x=r.useCallback(()=>{if(!t)return;const y=window.innerWidth||1280,$=window.innerHeight||800,p=c.current,N=a.current,C=p&&p.offsetWidth>0?p.offsetWidth:Math.min(ns,y-T*2),_=N?Math.max(0,N.scrollHeight-N.clientHeight):0,L=p&&p.offsetHeight>0?p.offsetHeight+_:Math.min(ls,$-T*2),k=as(t.anchorRect,C,L,y,$);g(E=>E&&E.left===k.left&&E.top===k.top&&E.maxHeight===k.maxHeight&&E.placement===k.placement?E:k)},[t]);r.useLayoutEffect(()=>{if(!t){g(null);return}x(),window.addEventListener("resize",x,{passive:!0});let y=null;return typeof ResizeObserver<"u"&&c.current&&(y=new ResizeObserver(()=>x()),y.observe(c.current)),()=>{window.removeEventListener("resize",x),y==null||y.disconnect()}},[t,t==null?void 0:t.loading,t==null?void 0:t.data,x]),r.useEffect(()=>{if(!t)return;const y=p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),u())},$=p=>{var C,_;const N=p.target;N&&((C=c.current)!=null&&C.contains(N)||(_=N.closest)!=null&&_.call(N,'[data-testid="live-diff-ai-explain-btn"]')||u())};return document.addEventListener("keydown",y,!0),document.addEventListener("mousedown",$,!0),()=>{document.removeEventListener("keydown",y,!0),document.removeEventListener("mousedown",$,!0)}},[t,u]);const h=r.useMemo(()=>Rn(t==null?void 0:t.spot.itemA,t==null?void 0:t.spot.itemB),[t==null?void 0:t.spot.itemA,t==null?void 0:t.spot.itemB]);if(!t||typeof document>"u")return null;const{spot:b,loading:j,error:S,data:w}=t,A=En[b.kind],M=as(t.anchorRect,ns,ls,window.innerWidth||1280,window.innerHeight||800),R=f??M;return ln.createPortal(e.jsxs("div",{ref:c,role:"dialog","aria-label":`红框差异 #${b.id} AI 讲解`,"data-testid":"spotlight-explain-popover","data-placement":R.placement,"data-spot-id":b.id,className:"bl-spotlight-popover",style:{left:`${R.left}px`,top:`${R.top}px`,maxHeight:`${R.maxHeight}px`},onPointerDown:y=>y.stopPropagation(),onMouseDown:y=>y.stopPropagation(),onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{className:"bl-spotlight-popover-head shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"bl-spotlight-spot-badge mono shrink-0",children:["#",b.id]}),e.jsx("span",{className:"bl-spotlight-kind-pill shrink-0","data-tone":A.tone,children:A.label}),e.jsx("h3",{className:"text-[13px] font-semibold leading-snug truncate",title:(w==null?void 0:w.title)||b.label,children:(w==null?void 0:w.title)||b.label})]}),e.jsx("button",{type:"button",onClick:u,"data-testid":"spotlight-explain-close","aria-label":"关闭差异讲解",title:"关闭 (Esc)",className:"bl-spotlight-close-btn shrink-0",children:e.jsx(xt,{size:14})})]}),e.jsxs("div",{className:"bl-spotlight-popover-meta shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 mono text-[10.5px]",children:[e.jsxs("span",{className:"truncate",style:{color:"var(--muted)"},title:s,children:["A ",s]}),e.jsx("span",{className:"opacity-40 shrink-0",children:"↔"}),e.jsxs("span",{className:"truncate font-medium",style:{color:"var(--accent)"},title:l,children:["B ",l]})]}),e.jsx("div",{className:"flex items-center gap-1 shrink-0 mono text-[10px]",children:j?e.jsx("span",{style:{color:"var(--accent)"},children:"分析中…"}):w?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bl-spotlight-source-badge","data-fallback":w.isFallback?"true":void 0,children:w.isFallback?"本地即时对比":w.provider}),w.cached&&e.jsx("span",{className:"bl-spotlight-cached-badge",children:"已缓存"})]}):null})]}),e.jsx("div",{ref:a,className:"flex-1 min-h-0 overflow-y-auto px-3.5 py-3 space-y-3 text-xs",children:j?e.jsxs("div",{"data-testid":"spotlight-explain-loading",className:"space-y-3 py-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[12px] font-medium",style:{color:"var(--accent)"},children:[e.jsx(Ze,{size:13,className:"animate-pulse shrink-0"}),e.jsx("span",{children:"AI 正在分析这处差异…"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"bl-spotlight-skeleton h-9 w-full"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("div",{className:"bl-spotlight-skeleton h-16"}),e.jsx("div",{className:"bl-spotlight-skeleton h-16"})]}),e.jsx("div",{className:"bl-spotlight-skeleton h-4 w-4/5"}),e.jsx("div",{className:"bl-spotlight-skeleton h-4 w-3/5"})]})]}):S?e.jsxs("div",{"data-testid":"spotlight-explain-error",className:"py-3 space-y-2.5",children:[e.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--diff-del-ink, var(--redline, #ef4444))"},children:S}),e.jsxs("button",{type:"button",onClick:()=>m(!1),"data-testid":"spotlight-explain-retry",className:"sheet-btn text-xs py-1 px-2.5",children:[e.jsx(ts,{size:12}),e.jsx("span",{children:"重试"})]})]}):w?e.jsxs(e.Fragment,{children:[e.jsx("div",{"data-testid":"spotlight-explain-summary",className:"bl-spotlight-summary-box text-[12.5px] leading-relaxed font-medium",children:w.summary}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"bl-spotlight-ab-card","data-side":"a",children:[e.jsx("div",{className:"caps text-[10px] mb-1",children:"原版 A"}),e.jsx("p",{className:"text-[11.5px] leading-relaxed break-words",style:{color:"var(--muted)"},children:w.beforeSummary||"无对应元素"}),(h.swatchesA.length>0||h.badgesA.length>0)&&e.jsxs("div",{className:"mt-2 pt-1.5 flex flex-wrap gap-1.5",style:{borderTop:"1px dashed var(--hair)"},children:[h.swatchesA.map(y=>e.jsxs("span",{"data-testid":`spotlight-swatch-a-${y.key}`,className:"bl-spotlight-swatch-chip mono",title:`${y.label}: ${y.value}`,children:[e.jsx("span",{className:"bl-spotlight-swatch-dot",style:{backgroundColor:y.value},"aria-hidden":"true"}),e.jsx("span",{className:"truncate max-w-[96px]",children:y.label})]},y.key)),h.badgesA.map(y=>e.jsxs("span",{className:"bl-spotlight-token-chip mono",title:`${y.label}: ${y.value}`,children:[y.label," ",y.value]},y.key))]})]}),e.jsxs("div",{className:"bl-spotlight-ab-card","data-side":"b",children:[e.jsx("div",{className:"caps text-[10px] mb-1",style:{color:"var(--accent)"},children:"对比版 B"}),e.jsx("p",{className:"text-[11.5px] leading-relaxed break-words",style:{color:"var(--ink)"},children:w.afterSummary||"已移除该元素"}),(h.swatchesB.length>0||h.badgesB.length>0)&&e.jsxs("div",{className:"mt-2 pt-1.5 flex flex-wrap gap-1.5",style:{borderTop:"1px dashed var(--hair)"},children:[h.swatchesB.map(y=>e.jsxs("span",{"data-testid":`spotlight-swatch-b-${y.key}`,className:"bl-spotlight-swatch-chip mono",title:`${y.label}: ${y.value}`,children:[e.jsx("span",{className:"bl-spotlight-swatch-dot",style:{backgroundColor:y.value},"aria-hidden":"true"}),e.jsx("span",{className:"truncate max-w-[96px]",children:y.label})]},y.key)),h.badgesB.map(y=>e.jsxs("span",{className:"bl-spotlight-token-chip mono",title:`${y.label}: ${y.value}`,children:[y.label," ",y.value]},y.key))]})]})]}),w.differences.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"caps text-[10px]",children:"具体差异要点"}),e.jsx("ul",{className:"space-y-1",children:w.differences.map((y,$)=>e.jsxs("li",{className:"flex items-start gap-2 text-[11.5px] leading-relaxed",style:{color:"var(--ink)"},children:[e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full mt-1.5 shrink-0",style:{background:"var(--accent)"},"aria-hidden":"true"}),e.jsx("span",{className:"break-words",children:y})]},$))})]}),w.impact&&e.jsxs("div",{className:"px-2.5 py-2 rounded-lg text-[11.5px] leading-relaxed",style:{background:"var(--surface)",border:"1px solid var(--hair)",color:"var(--muted)"},children:[e.jsx("span",{className:"caps text-[10px] mr-1.5",style:{color:"var(--ink)"},children:"体验影响"}),e.jsx("span",{children:w.impact})]}),w.relatedFiles.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"caps text-[10px]",children:"关联源码"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:w.relatedFiles.map(y=>e.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(y),className:"bl-spotlight-file-chip mono",title:`点击在代码差异视图中查看 ${y}`,children:y},y))})]})]}):null}),e.jsxs("div",{className:"bl-spotlight-popover-footer shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{type:"button",disabled:i<=1,onClick:()=>o(-1),"data-testid":"spotlight-explain-prev",className:"bl-spotlight-footer-btn disabled:opacity-35",title:"跳到上一处红框差异并讲解",children:[e.jsx(gn,{size:13}),e.jsx("span",{children:"上一处"})]}),e.jsxs("span",{className:"mono text-[10.5px] px-1",style:{color:"var(--faint)"},children:[Math.min(d+1,Math.max(1,i)),"/",Math.max(1,i)]}),e.jsxs("button",{type:"button",disabled:i<=1,onClick:()=>o(1),"data-testid":"spotlight-explain-next",className:"bl-spotlight-footer-btn disabled:opacity-35",title:"跳到下一处红框差异并讲解",children:[e.jsx("span",{children:"下一处"}),e.jsx(gs,{size:13})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",disabled:j,onClick:()=>m(!0),"data-testid":"spotlight-explain-refresh",className:"bl-spotlight-footer-btn disabled:opacity-35",title:"忽略缓存重新生成 AI 讲解",children:[e.jsx(ts,{size:11.5,className:j?"animate-spin":""}),e.jsx("span",{children:"重新讲解"})]}),n&&e.jsxs("button",{type:"button",onClick:()=>n(),"data-testid":"spotlight-explain-open-code",className:"bl-spotlight-footer-btn bl-spotlight-footer-btn-accent",title:"切换到代码对比视图",children:[e.jsx(ms,{size:11.5}),e.jsx("span",{children:"看代码差异"})]})]})]})]}),document.body)},Pn=({route:t,viewport:s,onViewportChange:l})=>e.jsxs("div",{className:"bl-viewport-ruler pt-3 mt-4 flex items-center justify-between gap-x-3 gap-y-1.5 flex-wrap text-xs shrink-0",style:{borderTop:"1px solid var(--hair)",color:"var(--faint)"},children:[e.jsxs("span",{className:"mono min-w-0 truncate max-w-full",children:["路由 ",t," · ",s.id==="auto"?"自适应宽度":`${s.width}×${s.height}`]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("span",{className:"caps",children:"视口"}),Ye.map(i=>e.jsx("button",{type:"button",onClick:()=>l(i),className:"mono text-xs transition-colors",style:{color:s.id===i.id?"var(--ink)":"var(--faint)",fontWeight:s.id===i.id?600:480,textDecoration:s.id===i.id?"underline":"none",textUnderlineOffset:"3px"},children:i.label},i.id))]})]});function ys(t){return typeof t=="number"&&Number.isInteger(t)&&t>0}function Ae(t){return typeof t=="number"&&Number.isFinite(t)}function In(t){return t.type!=="bl:spotlight-hover"?null:t.id===null?{id:null}:ys(t.id)?{id:t.id}:null}function _n(t){if(t.type!=="bl:spotlight-click"||!ys(t.id))return null;const s=t.rect;if(!s||typeof s!="object")return null;const l=s;return!Ae(l.left)||!Ae(l.top)||!Ae(l.width)||!Ae(l.height)||l.width<0||l.height<0||!Ae(t.clientX)||!Ae(t.clientY)?null:{id:t.id,rect:{left:l.left,top:l.top,width:l.width,height:l.height},clientX:t.clientX,clientY:t.clientY}}function He(t){if(!t)return null;try{const s=new URL(t);return s.protocol!=="http:"&&s.protocol!=="https:"||!s.origin||s.origin==="null"?null:s.origin}catch{return null}}function Fe(t,s){var c,a,f,g;const l=t.data;if(!l||typeof l!="object"||!l.__bl||t.source==null)return null;const i=((a=(c=s.a)==null?void 0:c.iframeRef.current)==null?void 0:a.contentWindow)??null,d=((g=(f=s.b)==null?void 0:f.iframeRef.current)==null?void 0:g.contentWindow)??null;if(i!==null&&d!==null&&i===d)return null;let u=null,o=null;if(i!==null&&t.source===i)u="a",o=s.a;else if(d!==null&&t.source===d)u="b",o=s.b;else return null;const m=l.slot;if(m!==void 0&&m!==""&&m!==u)return null;const n=He(o.previewUrl);return!n||t.origin!==n?null:{slot:u,origin:n,data:l}}let zn=0;function Hn({iframeARef:t,iframeBRef:s,basePreviewUrl:l,targetPreviewUrl:i,baseInstanceId:d,targetInstanceId:u,baseRef:o,targetRef:m,route:n,reloadNonce:c,hiddenSlots:a,postToFrame:f}){const[g,x]=r.useState(!1),[h,b]=r.useState([]),j=r.useRef(!1);j.current=g;const S=r.useRef(n),w=r.useRef(o),A=r.useRef(m),M=r.useRef(d),R=r.useRef(u),y=r.useRef({a:n,b:n}),$=r.useRef(0),p=r.useRef({a:0,b:0}),N=r.useRef(!0);r.useEffect(()=>(N.current=!0,()=>{N.current=!1}),[]);const C=!!(!a.a&&l||!a.b&&i),_=r.useCallback(()=>{f("a",{type:"bl:pick:stop"}),f("b",{type:"bl:pick:stop"})},[f]),L=r.useCallback(()=>{x(!1),_()},[_]),k=r.useCallback(()=>{C&&(x(!0),!a.a&&l&&f("a",{type:"bl:pick:start"}),!a.b&&i&&f("b",{type:"bl:pick:start"}))},[C,a.a,a.b,l,i,f]),E=r.useCallback(()=>{j.current?L():k()},[k,L]);r.useEffect(()=>{if(g){if(!C){x(!1),_();return}f("a",{type:!a.a&&l?"bl:pick:start":"bl:pick:stop"}),f("b",{type:!a.b&&i?"bl:pick:start":"bl:pick:stop"})}},[g,C,a.a,a.b,l,i,f,_]),r.useEffect(()=>{S.current!==n&&(S.current=n,y.current={a:n,b:n},$.current+=1,b([]),j.current&&L())},[n,L]),r.useEffect(()=>{(w.current!==o||M.current!==d)&&(w.current=o,M.current=d,y.current.a=n,p.current.a+=1,b(F=>F.filter(K=>K.slot!=="a")),j.current&&L())},[o,d,n,L]),r.useEffect(()=>{(A.current!==m||R.current!==u)&&(A.current=m,R.current=u,y.current.b=n,p.current.b+=1,b(F=>F.filter(K=>K.slot!=="b")),j.current&&L())},[m,u,n,L]),r.useEffect(()=>{c>0&&j.current&&L()},[c,L]),r.useEffect(()=>()=>{j.current&&(f("a",{type:"bl:pick:stop"}),f("b",{type:"bl:pick:stop"}))},[f]),r.useEffect(()=>{if(!g)return;const F=K=>{K.key==="Escape"&&(K.preventDefault(),L())};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[g,L]),r.useEffect(()=>{const F=K=>{const ee=Fe(K,{a:{iframeRef:t,previewUrl:l},b:{iframeRef:s,previewUrl:i}});if(!ee)return;const{slot:W,data:B}=ee;if(B.type==="bl:route"&&typeof B.route=="string"){const O=B.route.trim()||"/";y.current[W]!==O&&(y.current[W]=O,p.current[W]+=1,b(z=>z.filter(Q=>Q.slot!==W)));return}if(!a[W]){if(B.type==="bl:pick:cancelled"){j.current&&L();return}if(B.type==="bl:pick:selected"){if(!j.current)return;const O=jn(B.element);if(!O)return;const z=(W==="a"?o:m)||W.toUpperCase(),Q=W==="a"?d:u,q=y.current[W]||n,le=!!O.source,re=le?{...O,source:void 0}:O,V=$.current,H=p.current[W],ne=`pick-${++zn}`;b(D=>{const Z=D.findIndex(ie=>ie.slot===W&&ie.element.selector===re.selector&&ie.element.domPath===re.domPath);if(Z>=0){const ie=[...D];return ie[Z]={id:ne,slot:W,ref:z,route:q,element:re,sourceVerifying:le},ie}const ce={id:ne,slot:W,ref:z,route:q,element:re,sourceVerifying:le};return[...D.slice(-19),ce]}),le&&yt.sanitizePickedElements({ref:z,...Q?{instanceId:Q}:{},elements:[O]}).then(D=>{if(!N.current||$.current!==V||p.current[W]!==H)return;const Z=Array.isArray(D==null?void 0:D.elements)?D.elements[0]:null;b(ce=>ce.map(ie=>ie.id!==ne?ie:{...ie,element:Z??re,sourceVerifying:!1}))}).catch(()=>{!N.current||$.current!==V||p.current[W]!==H||b(D=>D.map(Z=>Z.id===ne?{...Z,sourceVerifying:!1}:Z))})}}};return window.addEventListener("message",F),()=>window.removeEventListener("message",F)},[t,s,l,i,d,u,o,m,n,a,L]);const I=r.useCallback(F=>{b(K=>K.filter(ee=>ee.id!==F))},[]),P=r.useCallback(()=>{b([])},[]);return{picking:g,canPick:C,pickedItems:h,startPicking:k,stopPicking:L,togglePicking:E,removePicked:I,clearPicked:P}}function is(t,s,l,i="/",d=!1){const[u,o]=r.useState(null),m=r.useCallback(a=>{var x;const f=He(l);if(!f)return;const g=t.current;try{(x=g==null?void 0:g.contentWindow)==null||x.postMessage({__bl_cmd:!0,...a},f)}catch{}},[t,l]),n=r.useCallback(()=>{m({type:"bl:scan-dom"})},[m]),c=r.useCallback(()=>{o(null)},[]);return r.useEffect(()=>{if(d)return;const a=f=>{const g=Fe(f,{[s]:{iframeRef:t,previewUrl:l}});if(!g||g.slot!==s||g.data.type!=="bl:dom-snapshot")return;const x=g.data,h={route:String(x.route||i),isLoginLike:!!x.isLoginLike,scrollHeight:Number(x.scrollHeight||0),items:Array.isArray(x.items)?x.items:[]};o(h)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[t,s,l,i,d]),{snapshot:u,post:m,rescan:n,resetSnapshot:c}}const Fn=/^(?:\/(?:auth|admin))?\/(?:login|signin|sign-in)\/?$|^\/auth\/callback\/?$/i;function ze(t){if(!t)return!1;const s=t.trim();if(!s)return!1;const l=s.indexOf("#/"),d=(l>=0?s.slice(l+1):s).split(/[?#]/,1)[0]||"/";return Fn.test(d)}function On(t,s){if(t&&!ze(t))return t;const l=s.find(i=>i.route&&!ze(i.route));return(l==null?void 0:l.route)||"/"}function Tn(t,s){const{iframeARef:l,iframeBRef:i,baseUrl:d,targetUrl:u,postToFrame:o,rescanAll:m,isLoginLikeA:n,isLoginLikeB:c,hiddenSlots:a}=s,f=!!(a!=null&&a.a),g=!!(a!=null&&a.b);r.useEffect(()=>{if(f&&g)return;const x=h=>{const b=Fe(h,{a:{iframeRef:l,previewUrl:d},b:{iframeRef:i,previewUrl:u}});if(!b)return;const{slot:j,data:S}=b;if(j==="a"&&f||j==="b"&&g)return;const w=j==="a"?"b":"a";if(!(w==="a"?f:g)){if(S.type==="bl:scroll"&&t)o(w,{type:"bl:scroll",x:S.x,y:S.y});else if(S.type==="bl:route"&&typeof S.route=="string"){const M=S.isLoginRoute===!0||S.isLoginLike===!0||ze(S.route);t&&!M&&!(w==="a"?!!n:!!c)&&o(w,{type:"bl:navigate",route:S.route}),setTimeout(()=>{m()},700)}}};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[t,l,i,d,u,o,m,n,c,f,g])}async function Vn(t,s,l){var x,h;const i=Fe(t,{a:{iframeRef:s.iframeARef,previewUrl:s.baseUrl},b:{iframeRef:s.iframeBRef,previewUrl:s.targetUrl}});if(!i||i.data.type!=="bl:storage")return;const{slot:d,data:u}=i;if(d==="a"&&((x=s.hiddenSlots)!=null&&x.a)||d==="b"&&((h=s.hiddenSlots)!=null&&h.b))return;const o=d==="a"?"b":"a",m=u.localStorage||{},n=u.sessionStorage||{};if(Object.keys(m).length+Object.keys(n).length===0)return;const a=JSON.stringify([m,n]);if(a===l.current)return;l.current=a;try{(await yt.saveRepoSession({localStorage:m,sessionStorage:n})).hasSession&&s.onSessionSaved()}catch{}const f=o==="a"?!!s.isLoginLikeA:!!s.isLoginLikeB,g=f&&s.targetRoute&&!ze(s.targetRoute)?s.targetRoute:void 0;s.postToFrame(o,{type:"bl:apply-storage",localStorage:m,sessionStorage:n,reload:f,...g?{navigateTo:g}:{}})}function Un(t){const s=r.useRef(""),{iframeARef:l,iframeBRef:i,baseUrl:d,targetUrl:u,postToFrame:o,onSessionSaved:m,isLoginLikeA:n,isLoginLikeB:c,targetRoute:a,sessionSyncVersion:f,hiddenSlots:g}=t,x=!!(g!=null&&g.a),h=!!(g!=null&&g.b),b=r.useRef(f??0);r.useEffect(()=>{if(x&&h)return;const j=S=>{Vn(S,{iframeARef:l,iframeBRef:i,baseUrl:d,targetUrl:u,postToFrame:o,onSessionSaved:m,isLoginLikeA:n,isLoginLikeB:c,targetRoute:a,sessionSyncVersion:f,hiddenSlots:{a:x,b:h}},s)};return window.addEventListener("message",j),()=>window.removeEventListener("message",j)},[l,i,d,u,o,m,n,c,a,f,x,h]),r.useEffect(()=>{const j=f??0;if(j<=b.current){b.current=j;return}b.current=j;const S=a&&!ze(a)?a:"/";!x&&n&&o("a",{type:"bl:navigate",route:S,forceReload:!0}),!h&&c&&o("b",{type:"bl:navigate",route:S,forceReload:!0})},[f,a,x,h,n,c,o])}function Ee(t,s,l,i){if(!t)return null;let d;try{d=new URL(t)}catch{return null}if(d.protocol!=="http:"&&d.protocol!=="https:")return null;const u=(s||"/").trim(),o=u.startsWith("/")?u:`/${u}`;let m;try{const n=new URL(o,d.origin);m=n.origin===d.origin?n:new URL("/",d.origin)}catch{m=new URL("/",d.origin)}return m.searchParams.set("_bl_slot",i),l>0&&m.searchParams.set("_bl",String(l)),m.toString()}const Kn=1500,Wn=350;function os(t,s){const l=He(t.previewUrl);return l?`${l}|${t.refName??""}|${t.instanceId??""}|${t.startedAt??""}|${s}`:null}function cs(t,s){const l=(t||"/").trim(),i=l.startsWith("/")?l:`/${l}`,d=He(s)??"http://127.0.0.1";try{const u=new URL(i,d);return u.origin!==d?"/":`${u.pathname}${u.search}${u.hash}`}catch{return"/"}}function Dn(t){const{route:s,reloadNonce:l,slotA:i,slotB:d,postToFrame:u,rescanSlot:o,timeoutMs:m=Kn}=t,n=os(i,l),c=os(d,l),a=Ee(i.previewUrl,s,l,"a"),f=Ee(d.previewUrl,s,l,"b"),[g,x]=r.useState(()=>({instanceKey:n,src:a})),[h,b]=r.useState(()=>({instanceKey:c,src:f})),j=n===null?null:g.instanceKey===n?g.src:a,S=c===null?null:h.instanceKey===c?h.src:f,w=r.useRef(0),A=r.useRef(1e5),M=r.useRef({}),R=r.useRef({}),y=r.useRef({route:s,instanceKeyA:n,instanceKeyB:c}),$=r.useRef({slotA:i,slotB:d,instanceKeyA:n,instanceKeyB:c,postToFrame:u,rescanSlot:o,timeoutMs:m});$.current={slotA:i,slotB:d,instanceKeyA:n,instanceKeyB:c,postToFrame:u,rescanSlot:o,timeoutMs:m};const p=r.useCallback(E=>{const I=M.current[E];I&&(window.clearTimeout(I.timer),delete M.current[E])},[]),N=r.useCallback(E=>{const I=R.current[E];I!==void 0&&(window.clearTimeout(I),delete R.current[E])},[]),C=r.useCallback((E,I)=>{if((E==="a"?$.current.instanceKeyA:$.current.instanceKeyB)!==I.instanceKey)return;const F=E==="a"?x:b,K=Ee(I.previewUrl,I.route,I.reloadNonce,E);K&&F(ee=>{if(ee.instanceKey!==I.instanceKey)return ee;if(ee.src===K){A.current+=1;const W=Ee(I.previewUrl,I.route,Math.max(I.reloadNonce,A.current),E);return{instanceKey:I.instanceKey,src:W??K}}return{instanceKey:I.instanceKey,src:K}})},[]);r.useEffect(()=>{const E=I=>{var H,ne;const P=I.data;if(!P||typeof P!="object")return;const F=P;if(F.type!=="bl:navigated"||F.__bl!==void 0&&F.__bl!==!0||I.source==null)return;const{slotA:K,slotB:ee,rescanSlot:W}=$.current,B=((H=K.iframeRef.current)==null?void 0:H.contentWindow)??null,O=((ne=ee.iframeRef.current)==null?void 0:ne.contentWindow)??null;if(B!==null&&O!==null&&B===O)return;let z=null,Q=null,q=!1;if(B!==null&&I.source===B)z="a",Q=K.previewUrl,q=K.hidden;else if(O!==null&&I.source===O)z="b",Q=ee.previewUrl,q=ee.hidden;else return;const le=F.slot;if(le!==void 0&&le!==""&&le!==z)return;const re=He(Q);if(!re||I.origin!==re)return;const V=M.current[z];if(!(!V||F.reqId!==V.reqId)){if(p(z),F.ok===!0){!q&&W&&(N(z),R.current[z]=window.setTimeout(()=>{var Z,ce;delete R.current[z],(z==="a"?$.current.slotA:$.current.slotB).hidden||(ce=(Z=$.current).rescanSlot)==null||ce.call(Z,z)},Wn));return}C(z,V)}};return window.addEventListener("message",E),()=>window.removeEventListener("message",E)},[C,p,N]),r.useEffect(()=>{var B;const E=y.current,I=E.route!==s,P=E.instanceKeyA!==n,F=E.instanceKeyB!==c;if(y.current={route:s,instanceKeyA:n,instanceKeyB:c},P&&(p("a"),N("a"),x({instanceKey:n,src:a})),F&&(p("b"),N("b"),b({instanceKey:c,src:f})),!I)return;const K=[];if(!P&&n!==null&&K.push({slot:"a",input:$.current.slotA,instanceKey:n,desiredUrl:a,setSrc:x}),!F&&c!==null&&K.push({slot:"b",input:$.current.slotB,instanceKey:c,desiredUrl:f,setSrc:b}),K.length===0)return;const ee=++w.current,W=$.current.timeoutMs;for(const O of K){const{slot:z,input:Q,instanceKey:q,desiredUrl:le,setSrc:re}=O;p(z),N(z);const V=cs(s,Q.previewUrl),H=cs(E.route,Q.previewUrl);if(V===H)continue;if(!(((B=Q.iframeRef.current)==null?void 0:B.contentWindow)??null)||!Q.previewUrl){re({instanceKey:q,src:le});continue}const D={reqId:ee,route:V,instanceKey:q,previewUrl:Q.previewUrl,reloadNonce:l,retriedOnLoad:!1,timer:0};D.timer=window.setTimeout(()=>{var Z;((Z=M.current[z])==null?void 0:Z.reqId)===ee&&(delete M.current[z],C(z,D))},W),M.current[z]=D,$.current.postToFrame(z,{type:"bl:navigate",route:V,path:V,reqId:ee})}},[s,l,n,c,a,f,C,p,N]);const _=r.useCallback(E=>{const I=M.current[E];!I||I.retriedOnLoad||(I.retriedOnLoad=!0,$.current.postToFrame(E,{type:"bl:navigate",route:I.route,path:I.route,reqId:I.reqId}))},[]),L=r.useCallback(()=>_("a"),[_]),k=r.useCallback(()=>_("b"),[_]);return r.useEffect(()=>()=>{p("a"),p("b"),N("a"),N("b")},[p,N]),{baseFrameSrc:j,targetFrameSrc:S,onFrameLoadA:L,onFrameLoadB:k}}function Xn({liveDiffs:t,postToFrame:s,paused:l=!1,spotlightEnabled:i,activeDiffIdx:d,onActiveDiffIdxChange:u,interactive:o=!1,hoverId:m}){const n=r.useRef(!1),c=r.useRef(m??null);m!==void 0&&(c.current=m);const a=r.useCallback((x,h)=>{const b=h?{interactive:o,hoverId:o?x:null}:{};if(l||!i||t.length===0){s("a",{type:"bl:highlight",highlights:[],activeId:null,...b}),s("b",{type:"bl:highlight",highlights:[],activeId:null,...b});return}const j=t[d]??t[0],S=t.filter(A=>typeof A.idxA=="number").map(A=>({id:A.id,idx:A.idxA})),w=t.filter(A=>typeof A.idxB=="number").map(A=>({id:A.id,idx:A.idxB}));s("a",{type:"bl:highlight",highlights:S,activeId:(j==null?void 0:j.id)??null,...b}),s("b",{type:"bl:highlight",highlights:w,activeId:(j==null?void 0:j.id)??null,...b})},[t,d,i,s,l,o]);r.useEffect(()=>{const x=o||n.current;n.current=o,o||(c.current=null),a(c.current,x)},[a,o,m]);const f=r.useCallback(x=>{c.current=x,!(!o||l||!i||t.length===0)&&a(x,!0)},[o,l,i,t.length,a]);return{focusDiffSpot:r.useCallback(x=>{if(l||t.length===0)return;const h=(x%t.length+t.length)%t.length;u(h);const b=t[h],j=t.filter(A=>typeof A.idxA=="number").map(A=>({id:A.id,idx:A.idxA})),S=t.filter(A=>typeof A.idxB=="number").map(A=>({id:A.id,idx:A.idxB})),w=o?{interactive:!0,hoverId:c.current}:{};typeof b.idxA=="number"?s("a",{type:"bl:focus",idx:b.idxA,highlights:j,activeId:b.id,...w}):s("a",{type:"bl:scroll",x:0,y:Math.max(0,b.y-160)}),typeof b.idxB=="number"?s("b",{type:"bl:focus",idx:b.idxB,highlights:S,activeId:b.id,...w}):s("b",{type:"bl:scroll",x:0,y:Math.max(0,b.y-160)})},[t,s,l,o,u]),setHoverId:f}}const qn=["bg","color","fontSize","fontWeight","fontFamily","borderRadius","borderColor"];function ds(t){return(t??"").replace(/\s+/g," ").trim()}function Gn(t,s){for(const l of qn)if(ds(t[l])!==ds(s[l]))return!0;return!1}function us(t){if(!t)return null;const s={tag:String(t.tag??""),text:String(t.text??"")};return typeof t.x=="number"&&Number.isFinite(t.x)&&(s.x=t.x),typeof t.y=="number"&&Number.isFinite(t.y)&&(s.y=t.y),typeof t.w=="number"&&Number.isFinite(t.w)&&(s.w=t.w),typeof t.h=="number"&&Number.isFinite(t.h)&&(s.h=t.h),typeof t.bg=="string"&&(s.bg=t.bg),typeof t.color=="string"&&(s.color=t.color),typeof t.fontSize=="string"&&(s.fontSize=t.fontSize),typeof t.fontWeight=="string"&&(s.fontWeight=t.fontWeight),typeof t.fontFamily=="string"&&(s.fontFamily=t.fontFamily),typeof t.borderRadius=="string"&&(s.borderRadius=t.borderRadius),typeof t.borderColor=="string"&&(s.borderColor=t.borderColor),typeof t.padding=="string"&&(s.padding=t.padding),typeof t.selector=="string"&&(s.selector=t.selector),s}function Yn(t,s){if(!t||!s)return[];const l=n=>n.replace(/\s+/g," ").trim(),i=n=>`${n.tag}::${l(n.text)}`,d=new Map;for(const n of t.items){const c=i(n),a=d.get(c)||[];a.push(n),d.set(c,a)}const u=new Map;for(const n of s.items){const c=i(n),a=u.get(c)||[];a.push(n),u.set(c,a)}const o=[];for(const n of s.items){const c=i(n);if(d.has(c)){const a=d.get(c)[0];a&&Gn(a,n)&&o.push({kind:"style",label:`样式调整「${n.text.slice(0,16)}」`,idxA:a.idx,idxB:n.idx,itemA:a,itemB:n,y:n.y})}else{const a=t.items.find(f=>!u.has(i(f))&&Math.abs(f.y-n.y)<36&&Math.abs(f.x-n.x)<120);o.push({kind:a?"changed":"added",label:a?`「${a.text.slice(0,12)}」→「${n.text.slice(0,14)}」`:`新增「${n.text.slice(0,16)}」`,idxA:a==null?void 0:a.idx,idxB:n.idx,...a?{itemA:a}:{},itemB:n,y:n.y})}}for(const n of t.items){const c=i(n);u.has(c)||o.some(f=>f.idxA===n.idx)||o.push({kind:"removed",label:`移除「${n.text.slice(0,16)}」`,idxA:n.idx,itemA:n,y:n.y})}o.sort((n,c)=>n.y-c.y);const m=[];for(const n of o)if(!m.some(a=>Math.abs(a.y-n.y)<22&&a.kind===n.kind)&&(m.push({...n,id:m.length+1}),m.length>=16))break;return m}const Jn=64;function Qn(t,s={}){return JSON.stringify([s.repoPath??"",s.aiFingerprint??"",s.reloadNonce??0,t.baseRef,t.targetRef,t.route,t.spotId,t.kind,t.label,t.elementA??null,t.elementB??null])}function Zn(){const t=typeof window<"u"&&window.innerWidth||1280;return{left:Math.max(24,Math.round(t*.42)),top:180,width:120,height:44}}function el({baseRef:t,targetRef:s,route:l,reloadNonce:i,compareSurface:d,liveDiffs:u,spotlightEnabled:o,spotlightPaused:m,picking:n,iframeARef:c,iframeBRef:a,basePreviewUrl:f,targetPreviewUrl:g,hiddenSlots:x,onEnableSpotlight:h,onStopPicking:b,onSelectDiffIdx:j,onHoverSpotChange:S}){const[w,A]=r.useState(!1),[M,R]=r.useState(null),y=r.useRef(null),$=Qe(B=>{var O;return((O=B.repo)==null?void 0:O.repoPath)??null}),p=Qe(B=>{var O;return(O=B.config)!=null&&O.ai?`${B.config.ai.provider}|${B.config.ai.model}|${B.config.ai.baseUrl}|${B.config.ai.hasApiKey?1:0}`:""}),N=r.useRef(new Map),C=r.useRef(null),_=r.useRef(!0),L=r.useCallback(B=>{y.current!==B&&(y.current=B,S==null||S(B))},[S]);r.useEffect(()=>(_.current=!0,()=>{var B;_.current=!1,(B=C.current)==null||B.abort(),C.current=null}),[]);const k=r.useCallback(()=>{C.current&&(C.current.abort(),C.current=null)},[]),E=r.useCallback(()=>{k(),R(null)},[k]),I=r.useCallback(()=>{k(),A(!1),L(null),R(null)},[k,L]),P=r.useCallback(()=>{if(w){k(),A(!1),L(null),R(null);return}h(),b(),A(!0)},[w,k,h,b,L]);r.useEffect(()=>{(n||!o)&&w&&I()},[n,o,w,I]),r.useEffect(()=>{k(),L(null),R(null)},[$,l,t,s,i,d,m,k,L]),r.useEffect(()=>{u.length===0&&(k(),L(null),R(null))},[u.length,k,L]);const F=r.useCallback((B,O,z,Q=!1)=>{if(!t||!s)return;const q={baseRef:t,targetRef:s,route:l.trim()||"/",spotId:B.id,kind:B.kind,label:B.label,sideClicked:O,elementA:us(B.itemA),elementB:us(B.itemB),...Q?{refresh:!0}:{}},le=Qn(q,{repoPath:$,aiFingerprint:p,reloadNonce:i});if(!Q){const V=N.current.get(le);if(V){k(),R({spot:B,sideClicked:O,anchorRect:z,loading:!1,error:null,data:{...V,cached:!0}});return}}k();const re=new AbortController;C.current=re,R({spot:B,sideClicked:O,anchorRect:z,loading:!0,error:null,data:null}),yt.explainSpotlightDiff(q,re.signal).then(V=>{if(!(!_.current||re.signal.aborted)){if(N.current.size>=Jn){const H=N.current.keys().next().value;H!==void 0&&N.current.delete(H)}N.current.set(le,V),R(H=>H&&H.spot.id===B.id?{...H,loading:!1,error:null,data:V}:H)}}).catch(V=>{if(!_.current||re.signal.aborted||V instanceof DOMException&&V.name==="AbortError")return;const H=V instanceof Error?V.message:"暂时无法获取 AI 差异讲解";R(ne=>ne&&ne.spot.id===B.id?{...ne,loading:!1,error:H}:ne)})},[k,p,t,i,$,l,s]),K=r.useCallback((B=!1)=>{M&&F(M.spot,M.sideClicked,M.anchorRect,B)},[M,F]),ee=r.useCallback(B=>{const O=u[B];O&&F(O,(M==null?void 0:M.sideClicked)??"b",(M==null?void 0:M.anchorRect)??Zn(),!1)},[M,F,u]),W=w&&d==="visual"&&o&&!m&&!n&&u.length>0;return r.useEffect(()=>{if(!W)return;const B=O=>{const z=Fe(O,{a:{iframeRef:c,previewUrl:f},b:{iframeRef:a,previewUrl:g}});if(!z||x[z.slot])return;const Q=In(z.data);if(Q){L(Q.id);return}const q=_n(z.data);if(q){const le=u.findIndex(D=>D.id===q.id);if(le<0)return;const re=u[le],V=z.slot==="a"?c.current:a.current,H=V==null?void 0:V.getBoundingClientRect();let ne=q.rect;if(H&&H.width>0&&H.height>0){const D=H.left+q.rect.left,Z=H.top+q.rect.top,ce=Math.max(H.left,Math.min(H.right,D)),ie=Math.max(H.top,Math.min(H.bottom,Z)),et=Math.max(ce,Math.min(H.right,D+q.rect.width)),Be=Math.max(ie,Math.min(H.bottom,Z+q.rect.height));ne={left:ce,top:ie,width:et-ce,height:Be-ie}}else H&&(ne={left:H.left+q.rect.left,top:H.top+q.rect.top,width:q.rect.width,height:q.rect.height});j(le),F(re,z.slot,ne,!1)}};return window.addEventListener("message",B),()=>window.removeEventListener("message",B)},[W,c,a,f,g,x,u,j,F,L]),{aiExplainMode:w,interactive:W,activeExplain:M,toggleAiExplainMode:P,disableAiExplainMode:I,closeExplain:E,retryExplain:K,explainSpotAt:ee}}const tl=({baseLabel:t,targetLabel:s})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"mono font-medium",style:{color:"var(--ink)"},children:["像素差异高亮 · ",t," vs ",s]}),e.jsx("span",{className:"mono",style:{color:"var(--muted)"},children:"纯黑区域 = 像素完全一致 · 亮色区域 = 发生视觉变化"})]});function sl(){return{clipPath:void 0,mixBlendMode:"difference",opacity:1,pointerEvents:"none"}}const vs={Legend:tl,getOverlayStyle:sl};function nl(t){const s=[],l=(t.error||t.statusMessage||"").trim();if(l)for(const o of l.split(/\r?\n/)){const m=o.trim();m&&s.push(m)}const i=(t.logs||[]).map(o=>o.trim()).filter(Boolean).slice(-6),d=i.filter(o=>/error|err!|fail|exception|enoent|eaddrinuse|cannot|未找到|失败/i.test(o)),u=d.length>0?d:i;for(const o of u.slice(-3))s.includes(o)||s.push(o);return s.slice(0,3)}const fs=({role:t,branchRef:s,inst:l,isTargetSlot:i=!1,branches:d,baseRef:u,targetRef:o,onBaseChange:m,onTargetChange:n,onRetryStart:c,onBackToTree:a,onOpenLogs:f})=>{if(!s){const x=d.filter(h=>h.ref!==(i?u:o));return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center max-w-md mx-auto",children:[e.jsxs("div",{className:"text-[20px] font-semibold tracking-tight mb-2",children:["请选择",t]}),e.jsx("p",{className:"text-[13px] mb-5",style:{color:"var(--muted)"},children:"可直接点选下方分支立即开启对比,或返回分支树全景挑选。"}),e.jsx("div",{className:"flex flex-wrap items-center justify-center gap-2 mb-5",children:x.slice(0,6).map(h=>e.jsx("button",{type:"button",onClick:()=>i?n(h.ref):m(h.ref),className:"bl-pill-action text-[13px] font-medium",children:h.label},h.ref))}),e.jsx("button",{type:"button",onClick:a,className:"sheet-link text-[13px]",children:"← 返回分支树挑选"})]})}if((l==null?void 0:l.status)==="error"){const x=nl(l);return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center max-w-md mx-auto",children:[e.jsx("div",{className:"caps mb-2",style:{color:"var(--redline, var(--accent))"},children:"■ 启动失败"}),x.length>0?e.jsx("div",{"data-testid":"frame-error-lines",className:"w-full mb-4 p-2.5 rounded-lg text-left mono text-[11.5px] leading-relaxed space-y-1 break-all",style:{background:"var(--surface)",border:"1px solid var(--hair-strong)",color:"var(--muted)"},children:x.map((h,b)=>e.jsx("div",{className:"line-clamp-2",children:h},b))}):e.jsx("p",{className:"text-[13px] mb-4 break-all",style:{color:"var(--muted)"},children:"预览服务未能正常启动,请检查项目启动命令或查看运行日志。"}),e.jsxs("div",{className:"flex items-center justify-center flex-wrap gap-3 text-[12.5px]",children:[e.jsx("button",{type:"button",onClick:()=>c(s),className:"sheet-btn sheet-btn-primary",children:"重试启动 →"}),e.jsx("button",{type:"button",onClick:()=>Je.getState().setSettingsOpen(!0,"repo"),className:"sheet-btn",children:"配置启动命令 →"}),e.jsx("button",{type:"button",onClick:f,className:"hover:underline underline-offset-4",style:{color:"var(--muted)"},children:"查看日志"})]})]})}const g=(l==null?void 0:l.status)==="preparing"||(l==null?void 0:l.status)==="installing"||(l==null?void 0:l.status)==="starting";return e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-center",children:g?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bl-spinner mb-3.5"}),e.jsx("div",{className:"text-[13.5px] font-medium mb-2",style:{color:"var(--ink)"},children:(l==null?void 0:l.statusMessage)||"正在启动预览…"}),l&&l.logs.length>0&&e.jsx("div",{className:"mt-2 w-full max-w-sm p-2.5 text-left mono text-[11px] max-h-20 overflow-hidden",style:{borderTop:"1px solid var(--hair)",color:"var(--faint)"},children:l.logs.slice(-3).map((x,h)=>e.jsx("div",{className:"truncate",children:x},h))})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-[13.5px] mb-3.5",style:{color:"var(--muted)"},children:["分支"," ",e.jsx("span",{className:"mono font-medium",style:{color:"var(--ink)"},children:s})," ","尚未启动预览服务"]}),e.jsx("button",{type:"button",onClick:()=>c(s),className:"sheet-btn sheet-btn-primary",children:"启动预览 →"})]})})},ll=({baseLabel:t,targetLabel:s,opacity:l})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"mono font-medium",style:{color:"var(--ink)"},children:["透明叠图 · A ",t," + B ",s]}),e.jsxs("span",{className:"mono",style:{color:"var(--muted)"},children:["当前 B 叠层不透明度:",l,"%"]})]});function rl(t){return{clipPath:void 0,mixBlendMode:"normal",opacity:t/100,pointerEvents:"none"}}const js={Legend:ll,getOverlayStyle:rl},al=({label:t,url:s})=>e.jsxs("div",{className:"bl-frame-head flex items-center justify-between shrink-0",children:[e.jsxs("span",{children:[e.jsx("span",{className:"caps mr-2",style:{color:"var(--accent)"},children:"B"}),e.jsx("span",{className:"font-medium",children:t})]}),s&&e.jsx("a",{href:s,target:"_blank",rel:"noreferrer",className:"mono text-[11.5px] hover:underline",style:{color:"var(--muted)"},children:"独立打开 ↗"})]}),bt={Header:al,containerClass:"flex-1 flex flex-col min-h-0",slotBClass:"bl-frame bl-frame-primary flex-1 flex flex-col min-h-0"},il=({baseLabel:t,targetLabel:s,sliderPos:l,percentRef:i})=>e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"mono font-medium",style:{color:"var(--ink)"},children:["左 · A 原版:",t]}),e.jsxs("span",{className:"mono",style:{color:"var(--faint)"},children:["左右拖动中线对比(",e.jsx("span",{ref:i,children:Math.round(l)}),"%)"]}),e.jsxs("span",{className:"mono font-medium",style:{color:"var(--accent)"},children:["右 · B 对比:",s]})]}),ol=({sliderPos:t,onDragStart:s})=>e.jsx("div",{"data-testid":"compare-slider-handle",onMouseDown:s,style:{left:`var(--bl-slider-pos, ${t}%)`,background:"var(--accent)"},className:"absolute top-0 bottom-0 w-[2px] -ml-[1px] cursor-ew-resize z-20",children:e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2 w-7 h-11 flex items-center justify-center mono text-xs text-white",style:{background:"var(--accent)",borderRadius:"999px"},children:"⇄"})});function cl(t,s){return{clipPath:`inset(0 0 0 var(--bl-slider-pos, ${t}%))`,mixBlendMode:"normal",opacity:1,pointerEvents:s?"none":"auto"}}const gt={Legend:il,Handle:ol,getOverlayStyle:cl},dl=({slot:t,label:s,url:l})=>e.jsxs("div",{className:"bl-frame-head flex items-center justify-between shrink-0",children:[e.jsxs("span",{className:"truncate min-w-0",children:[e.jsx("span",{className:"caps mr-2",style:t==="B"?{color:"var(--accent)"}:void 0,children:t}),e.jsx("span",{className:"font-medium",children:s})]}),l&&e.jsx("a",{href:l,target:"_blank",rel:"noreferrer",className:"mono text-[11.5px] hover:underline shrink-0 ml-2 whitespace-nowrap",style:{color:"var(--muted)"},children:"独立打开 ↗"})]}),_e={Header:dl,containerClass:"bl-split-grid flex-1 grid grid-cols-2 gap-4 min-h-0 min-w-0",slotAClass:"bl-frame bl-split-slot flex flex-col min-w-0 min-h-0",slotBClass:"bl-frame bl-frame-primary bl-split-slot flex flex-col min-w-0 min-h-0"};function ws(t,s,l,i){const d=s&&!!l,u=!d&&(t==="slider"||t==="blend"||t==="onion")&&(!l||!i);return{a:!d&&t==="single"||u&&!!l,b:d||u&&!!i}}function ul(t){const{viewMode:s,holdingOriginal:l,sliderPos:i,opacity:d,draggingSlider:u,viewport:o,baseUrl:m,targetUrl:n,stageActive:c=!0}=t,a=o.id==="auto",f=a?{width:"100%",height:"100%"}:{width:`${o.width}px`,height:`${o.height}px`,flexShrink:0},g=a?"flex-1 min-h-0 flex items-stretch justify-stretch overflow-hidden bg-white":"flex-1 min-h-0 overflow-auto p-3",x=l&&!!m,h=!x&&(s==="slider"||s==="blend"||s==="onion"),b=h&&!!m&&!!n,j=h&&(!m||!n),S=!x&&s==="split",w=!x&&s==="single",A=ws(s,l,m,n),M=!c||A.a,R=!c||A.b,y=b?s==="slider"?gt.getOverlayStyle(i,u):s==="blend"?vs.getOverlayStyle():js.getOverlayStyle(d):void 0,$=x||b?void 0:{...f,border:a?0:"1px solid var(--hair-strong)"},p=b?void 0:{...f,border:a?0:"1px solid var(--hair-strong)"};return{showHoldingOriginal:x,isSplitMode:S,isSingleMode:w,isOverlayReady:b,isOverlayPending:j,hiddenA:M,hiddenB:R,outerScrollClass:x?g:b?a?"flex-1 min-h-0 flex":"flex-1 min-h-0 overflow-auto p-1":"flex-1 min-h-0 flex flex-col",outerScrollStyle:x?{background:a?void 0:"var(--surface)"}:void 0,canvasInnerClass:x?`bl-frame bl-frame-body bg-white ${a?"":"mx-auto"}`:S?_e.containerClass:w?bt.containerClass:b?`bl-frame bl-frame-primary bl-frame-body relative overflow-hidden bg-white select-none ${a?"":"mx-auto"}`:"bl-split-grid w-full h-full grid grid-cols-2 gap-6 min-h-0 min-w-0",canvasInnerStyle:x?{...f,border:"2px solid var(--accent)"}:b?{...f,...s==="slider"?{"--bl-slider-pos":`${i}%`}:{}}:void 0,slotAClass:x?"w-full h-full":S?_e.slotAClass:w?"hidden":b?"absolute inset-0":"bl-frame flex min-w-0 min-h-0",slotBClass:x?"hidden":S?_e.slotBClass:w?bt.slotBClass:b?"absolute inset-0":"bl-frame bl-frame-primary flex min-w-0 min-h-0",slotBStyle:y,hostAClass:x||b?"w-full h-full":j?m?"hidden":"w-full h-full flex":g,hostAStyle:S?{background:m?a?"#ffffff":"var(--surface)":"var(--bg)"}:j&&!m?{background:"var(--bg)"}:void 0,hostBClass:b?"w-full h-full":j?n?"hidden":"w-full h-full flex":g,hostBStyle:S||w?{background:n?a?"#ffffff":"var(--surface)":"var(--bg)"}:j&&!n?{background:"var(--bg)"}:void 0,iframeAClass:x?"w-full h-full border-0 bg-white block":b?`w-full h-full border-0 bg-white block ${u?"pointer-events-none":""}`:`bg-white block ${a?"":"mx-auto shadow-sm"} ${M?"pointer-events-none":""}`,iframeAStyle:M?{...$,pointerEvents:"none"}:$,iframeBClass:b?"w-full h-full border-0 bg-white block":`bg-white block ${a?"":"mx-auto shadow-sm"} ${R?"pointer-events-none":""}`,iframeBStyle:R?{...p,pointerEvents:"none"}:p}}const fl=({viewMode:t,holdingOriginal:s,sliderPos:l,opacity:i,draggingSlider:d,viewport:u,branches:o,baseRef:m,targetRef:n,baseLabel:c,targetLabel:a,baseUrl:f,targetUrl:g,baseFrameSrc:x,targetFrameSrc:h,onFrameLoadA:b,onFrameLoadB:j,baseInst:S,targetInst:w,sliderContainerRef:A,sliderPercentRef:M,iframeARef:R,iframeBRef:y,stageActive:$=!0,onDragStart:p,onBaseChange:N,onTargetChange:C,onRetryStart:_,onBackToTree:L,onOpenLogs:k})=>{const E=x!==void 0?x:f,I=h!==void 0?h:g,P=ul({viewMode:t,holdingOriginal:s,sliderPos:l,opacity:i,draggingSlider:d,viewport:u,baseUrl:f,targetUrl:g,stageActive:$});return e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[P.showHoldingOriginal?e.jsxs("div",{className:"w-full mb-2.5 flex items-baseline justify-between text-[13px] shrink-0",children:[e.jsxs("span",{className:"mono font-medium",style:{color:"var(--accent)"},children:["■ 正在闪看原版 · ",c]}),e.jsx("span",{className:"caps",children:"松开 SPACE 恢复"})]}):P.isOverlayReady?e.jsx("div",{className:"mb-2.5 flex items-center justify-between gap-3 text-xs shrink-0 flex-wrap",children:t==="slider"?e.jsx(gt.Legend,{baseLabel:c,targetLabel:a,sliderPos:l,percentRef:M}):t==="blend"?e.jsx(vs.Legend,{baseLabel:c,targetLabel:a}):e.jsx(js.Legend,{baseLabel:c,targetLabel:a,opacity:i})}):null,e.jsx("div",{className:P.outerScrollClass,style:P.outerScrollStyle,children:e.jsxs("div",{ref:A,className:P.canvasInnerClass,style:P.canvasInnerStyle,children:[e.jsxs("div",{className:P.slotAClass,"aria-hidden":P.hiddenA?"true":void 0,children:[P.isSplitMode?e.jsx(_e.Header,{slot:"A",label:c,url:f}):null,e.jsx("div",{className:P.hostAClass,style:P.hostAStyle,children:E?e.jsx("iframe",{ref:R,src:E,onLoad:b,title:P.showHoldingOriginal?"原版快览":P.isOverlayReady?"叠加原版":`原版-${m}`,"aria-hidden":P.hiddenA?"true":void 0,tabIndex:P.hiddenA?-1:void 0,style:P.iframeAStyle,className:P.iframeAClass},"iframe-a"):e.jsx("div",{className:"w-full h-full flex",style:{background:"var(--bg)"},children:e.jsx(fs,{role:"原版分支 A",branchRef:m,inst:S,branches:o,baseRef:m,targetRef:n,onBaseChange:N,onTargetChange:C,onRetryStart:_,onBackToTree:L,onOpenLogs:k})})},"host-a"),P.isOverlayPending&&f?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm",style:{color:"var(--muted)"},children:"原版 A 已就绪"},"ready-a"):null]},"slot-a"),e.jsxs("div",{className:P.slotBClass,style:P.slotBStyle,"aria-hidden":P.hiddenB?"true":void 0,children:[P.isSplitMode?e.jsx(_e.Header,{slot:"B",label:a,url:g}):P.isSingleMode?e.jsx(bt.Header,{label:a,url:g}):null,e.jsx("div",{className:P.hostBClass,style:P.hostBStyle,children:I?e.jsx("iframe",{ref:y,src:I,onLoad:j,title:P.isSingleMode?`独览-${n}`:P.isOverlayReady?"叠加新版":`新版-${n}`,"aria-hidden":P.hiddenB?"true":void 0,tabIndex:P.hiddenB?-1:void 0,style:P.iframeBStyle,className:P.iframeBClass},"iframe-b"):e.jsx("div",{className:"w-full h-full flex",style:{background:"var(--bg)"},children:e.jsx(fs,{role:"对比分支 B",branchRef:n,inst:w,isTargetSlot:!0,branches:o,baseRef:m,targetRef:n,onBaseChange:N,onTargetChange:C,onRetryStart:_,onBackToTree:L,onOpenLogs:k})})},"host-b"),P.isOverlayPending&&g?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm",style:{color:"var(--muted)"},children:"对比版 B 已就绪"},"ready-b"):null]},"slot-b"),P.isOverlayReady&&t==="slider"?e.jsx(gt.Handle,{sliderPos:l,onDragStart:p}):null]},"canvas-inner")},"viewport-scroll-outer")]})},pl=hs.lazy(()=>ps(()=>import("./CodeDiffStage-BAkeoFAz.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(t=>({default:t.CodeDiffStage}))),hl=hs.lazy(()=>ps(()=>import("./ResponsiveMatrixStage-IZfS6JC4.js"),__vite__mapDeps([7,1,2,3,4,6]),import.meta.url).then(t=>({default:t.ResponsiveMatrixStage}))),jl=({active:t=!0,branches:s,instances:l,baseRef:i,targetRef:d,compareSurface:u="visual",codeDiffMode:o,changeSummary:m,onCompareSurfaceChange:n,onCodeDiffModeChange:c,onOpenBackendDiff:a,route:f,onRouteChange:g,compareTargets:x,allRoutes:h,routeParams:b,onSaveRouteParams:j,mockAuthEnabled:S,onToggleMockAuth:w,canAutoLogin:A,onAutoLogin:M,sessionSyncVersion:R,hasSavedSession:y,onSessionSaved:$,onClearSession:p,viewport:N,onViewportChange:C,onBaseChange:_,onTargetChange:L,onSwap:k,onRetryStart:E,onGoAnnotate:I,onOpenPrDraft:P,onBackToTree:F,onOpenLogs:K})=>{var Tt,Vt,Ut,Kt,Wt,Dt,Xt,qt;const{isHarnessPanel:ee}=tn(),W=r.useRef(!1),[B,O]=r.useState(()=>ee?"single":"split"),z=r.useCallback(v=>{W.current=!0,O(v)},[]);r.useEffect(()=>{ee&&!W.current&&O("single")},[ee]);const[Q,q]=r.useState(50),[le,re]=r.useState(50),[V,H]=r.useState(!1),[ne,D]=r.useState(!1),[Z,ce]=r.useState(0),[ie,et]=r.useState(!0),[Be,vt]=r.useState(!1),[tt,jt]=r.useState(!1),[wt,ks]=r.useState(void 0),[Ns,kt]=r.useState(null),[st,Nt]=r.useState(!0),[Re,nt]=r.useState(0),Ss=o??wt,St=r.useRef(null),Oe=r.useRef(null),lt=r.useRef(null),rt=r.useRef(Q);rt.current=Q;const me=r.useRef(null),xe=r.useRef(null),he=r.useRef(null),Mt=r.useRef(null),at=r.useRef(null),Te=r.useRef(null),Ms=r.useCallback(v=>{var U;(U=Te.current)==null||U.call(Te,v)},[]),te=t&&u==="visual",[it,Cs]=r.useState(()=>te);r.useEffect(()=>{te&&!it&&Cs(!0)},[te,it]);const de=i?l[i]:void 0,ue=d?l[d]:void 0,ot=((Tt=s.find(v=>v.ref===i))==null?void 0:Tt.label)||i||"未选择",ct=((Vt=s.find(v=>v.ref===d))==null?void 0:Vt.label)||d||"未选择",Ve=(de==null?void 0:de.status)==="ready"?de.previewUrl:null,Ue=(ue==null?void 0:ue.status)==="ready"?ue.previewUrl:null,Ct=(de==null?void 0:de.status)==="ready"?de.id:null,At=(ue==null?void 0:ue.status)==="ready"?ue.id:null,As=(de==null?void 0:de.status)==="ready"?de.startedAt:null,Ls=(ue==null?void 0:ue.status)==="ready"?ue.startedAt:null,Ne=Ee(Ve,f,Z,"a"),Se=Ee(Ue,f,Z,"b"),dt=ws(B,ne,Ne,Se),se=r.useMemo(()=>te?dt:{a:!0,b:!0},[te,dt.a,dt.b]),ut=se.a||se.b,je=is(me,"a",Ne,f,se.a),we=is(xe,"b",Se,f,se.b),{post:Lt,rescan:Ke,resetSnapshot:Et}=je,{post:Bt,rescan:We,resetSnapshot:Rt}=we,fe=r.useMemo(()=>Yn(je.snapshot,we.snapshot),[je.snapshot,we.snapshot]),$t=!!((Ut=je.snapshot)!=null&&Ut.isLoginLike||(Kt=we.snapshot)!=null&&Kt.isLoginLike),ge=r.useCallback((v,U)=>{v==="a"?Lt(U):Bt(U)},[Lt,Bt]),De=r.useCallback(()=>{se.a||Ke(),se.b||We()},[Ke,We,se.a,se.b]),Es=r.useCallback(v=>{v==="a"?se.a||Ke():se.b||We()},[Ke,We,se.a,se.b]),{baseFrameSrc:Bs,targetFrameSrc:Rs,onFrameLoadA:$s,onFrameLoadB:Ps}=Dn({route:f,reloadNonce:Z,slotA:{iframeRef:me,previewUrl:Ve,refName:i,instanceId:Ct,startedAt:As,hidden:se.a},slotB:{iframeRef:xe,previewUrl:Ue,refName:d,instanceId:At,startedAt:Ls,hidden:se.b},postToFrame:ge,rescanSlot:Es}),Pt=r.useCallback(()=>{ge("a",{type:"bl:highlight",highlights:[],activeId:null}),ge("b",{type:"bl:highlight",highlights:[],activeId:null})},[ge]),be=ut||B==="blend",Is=r.useCallback(()=>{Nt(v=>!v)},[]),_s=r.useCallback(()=>{Nt(!0)},[]),It=r.useCallback(()=>{nt(0)},[]),Me=r.useCallback(v=>{he.current!==null&&(window.clearTimeout(he.current),he.current=null),v&&Pt(),!(!te||be)&&(he.current=window.setTimeout(()=>{he.current=null,De()},120))},[Pt,te,be,De]);r.useEffect(()=>{const v=`${B}:${N.id}:${N.width}x${N.height}`,U=Mt.current;if(Mt.current={key:v,paused:be},!U||U.key===v)return;const G=!U.paused&&!be;Me(G)},[B,N.id,N.width,N.height,be,Me]),r.useEffect(()=>{if(!te||typeof ResizeObserver>"u")return;const v=St.current;if(!v)return;at.current=null;const U=new ResizeObserver(G=>{var ae;const Y=(ae=G[0])==null?void 0:ae.contentRect;if(!Y)return;const pe=Math.round(Y.width),J=Math.round(Y.height);if(pe<=0||J<=0)return;const oe=at.current;at.current={width:pe,height:J},oe&&(Math.abs(oe.width-pe)<2&&Math.abs(oe.height-J)<2||Me(!be))});return U.observe(v),()=>{U.disconnect()}},[te,be,Me]);const _t=r.useRef(te);r.useEffect(()=>{const v=_t.current;if(_t.current=te,!te){he.current!==null&&(window.clearTimeout(he.current),he.current=null);return}v||Me(!1)},[te,Me]),r.useEffect(()=>()=>{he.current!==null&&(window.clearTimeout(he.current),he.current=null)},[]);const{picking:$e,canPick:zs,pickedItems:zt,stopPicking:Ce,togglePicking:Hs,removePicked:Fs,clearPicked:Os}=Hn({iframeARef:me,iframeBRef:xe,basePreviewUrl:Ve,targetPreviewUrl:Ue,baseInstanceId:Ct,targetInstanceId:At,baseRef:i,targetRef:d,route:f,reloadNonce:Z,hiddenSlots:se,postToFrame:ge});r.useEffect(()=>{!te&&$e&&Ce()},[te,$e,Ce]);const{aiExplainMode:Ts,interactive:Ht,activeExplain:ke,toggleAiExplainMode:Vs,disableAiExplainMode:Us,closeExplain:ft,retryExplain:Ks,explainSpotAt:Ft}=el({baseRef:i,targetRef:d,route:f,reloadNonce:Z,compareSurface:u,liveDiffs:fe,spotlightEnabled:st,spotlightPaused:be,picking:$e,iframeARef:me,iframeBRef:xe,basePreviewUrl:Ve,targetPreviewUrl:Ue,hiddenSlots:se,onEnableSpotlight:_s,onStopPicking:Ce,onSelectDiffIdx:nt,onHoverSpotChange:Ms}),{focusDiffSpot:pt,setHoverId:Ws}=Xn({liveDiffs:fe,postToFrame:ge,paused:be,spotlightEnabled:st,activeDiffIdx:Re,onActiveDiffIdxChange:nt,interactive:Ht});Te.current=Ws;const Ds=r.useCallback(v=>{if(fe.length===0)return;const G=(((ke?Math.max(0,fe.findIndex(Y=>Y.id===ke.spot.id)):Re)+v)%fe.length+fe.length)%fe.length;pt(G),Ft(G)},[Re,ke,Ft,pt,fe]),Xs=r.useCallback(v=>{var Gt,Yt,Jt,Qt,Zt;if(v.length===0||v.some(X=>X.sourceVerifying))return;Ce();const U=((Gt=Qe.getState().repo)==null?void 0:Gt.branches)??[],G=((Yt=s.find(X=>X.isCurrent&&!X.isWorkingTree))==null?void 0:Yt.ref)||((Jt=U.find(X=>X.isCurrent&&!X.isWorkingTree))==null?void 0:Jt.ref)||"",Y=X=>X&&X!=="__working__"?X:null,pe=X=>(X.slot==="a"?i:d)||X.ref,J=!G&&v.some(X=>pe(X)==="__working__"),oe=new Set(v.map(X=>X.slot));let ae="",ye=!1,qe;if(J)ae="",ye=!0,qe=Y(d)||Y(i)||void 0;else if(oe.size===1){const X=v[0].slot,Pe=pe(v[0]),Ie=X==="a"?d:i;ae=Pe==="__working__"?G:Pe||"";const mt=Y(Ie);mt&&mt!==ae&&(qe=mt)}else{const X=d==="__working__"?G:d||"",Pe=i==="__working__"?G:i||"";ae=Y(X)||Y(Pe)||((Qt=Qe.getState().repo)==null?void 0:Qt.baseBranch)||"main";const Ie=ae===Y(X)?Y(Pe):Y(X);Ie&&Ie!==ae&&(qe=Ie)}const en=((Zt=v[v.length-1])==null?void 0:Zt.route)||f;sn.getState().openComposer({sourceRef:ae,...ye?{requireExplicitSourceRef:!0}:{},regions:[],pickedElements:v.map(X=>({...X.element,route:X.route||f})),route:en,viewport:{width:N.width,height:N.height},compareWith:qe})},[Ce,s,d,i,f,N.width,N.height]);r.useEffect(()=>{Et(),Rt(),It(),kt(null)},[f,i,d,Z,Et,Rt,It]),r.useEffect(()=>{var v,U;se.a&&document.activeElement===me.current&&((v=me.current)==null||v.blur()),se.b&&document.activeElement===xe.current&&((U=xe.current)==null||U.blur())},[se.a,se.b]);const qs=r.useMemo(()=>On(f,x),[f,x]),Gs=r.useCallback(async()=>{if(!(!w||Be)){vt(!0);try{await w(!S),ce(v=>v+1)}catch(v){Je.getState().pushToast({tone:"warning",title:"切换 Mock 免登失败",detail:v instanceof Error?v.message:String(v)})}finally{vt(!1)}}},[w,Be,S]),Ys=r.useCallback(async()=>{if(!(!M||tt)){jt(!0);try{await M(),ce(v=>v+1)}catch(v){Je.getState().pushToast({tone:"warning",title:"一键测试登录失败",detail:v instanceof Error?v.message:String(v)})}finally{jt(!1)}}},[M,tt]);Tn(ie,{iframeARef:me,iframeBRef:xe,baseUrl:Ne,targetUrl:Se,postToFrame:ge,rescanAll:De,isLoginLikeA:(Wt=je.snapshot)==null?void 0:Wt.isLoginLike,isLoginLikeB:(Dt=we.snapshot)==null?void 0:Dt.isLoginLike,hiddenSlots:se}),Un({iframeARef:me,iframeBRef:xe,baseUrl:Ne,targetUrl:Se,postToFrame:ge,onSessionSaved:$,isLoginLikeA:(Xt=je.snapshot)==null?void 0:Xt.isLoginLike,isLoginLikeB:(qt=we.snapshot)==null?void 0:qt.isLoginLike,targetRoute:qs,sessionSyncVersion:R,hiddenSlots:se});const ht=r.useCallback(v=>{c?c(v):(ks(v),nn(v))},[c]),Xe=r.useCallback(v=>{if(a){a(v);return}ht(v),n==null||n("code")},[a,ht,n]),Js=r.useCallback(v=>{ft(),kt(v??null),Xe("code")},[ft,Xe]),Ot=(m==null?void 0:m.backendFiles)??0,Qs=u==="visual"&&!!(je.snapshot&&we.snapshot)&&!ut&&fe.length===0&&!$t&&Ot>0,Zs=r.useCallback((v,U)=>{g(v);const G=Ye.find(Y=>Y.id===U.id)||Ye.find(Y=>Y.width===U.width&&Y.height===U.height)||Ye[0];C(G),n==null||n("visual")},[g,C,n]);return r.useEffect(()=>{if(!te)return;const v=J=>{if(!J)return!1;const oe=J.tagName;return oe==="BUTTON"||oe==="A"||oe==="INPUT"||oe==="TEXTAREA"||oe==="SELECT"||J.isContentEditable?!0:!!J.closest('button, a, input, textarea, select, [contenteditable="true"], [role="dialog"]')},U=J=>{if(J.code==="Space"&&!J.repeat&&!J.defaultPrevented&&!J.metaKey&&!J.ctrlKey&&!J.altKey){const oe=(J.target instanceof HTMLElement?J.target:null)??(document.activeElement instanceof HTMLElement?document.activeElement:null);if(v(oe)||document.querySelector('[role="dialog"][aria-modal="true"]'))return;J.preventDefault(),D(!0)}},G=J=>{J.code==="Space"&&D(!1)},Y=()=>D(!1),pe=()=>{document.hidden&&D(!1)};return window.addEventListener("keydown",U),window.addEventListener("keyup",G),window.addEventListener("blur",Y),document.addEventListener("visibilitychange",pe),()=>{window.removeEventListener("keydown",U),window.removeEventListener("keyup",G),window.removeEventListener("blur",Y),document.removeEventListener("visibilitychange",pe),D(!1)}},[te]),r.useEffect(()=>{var oe;if(!V)return;if(!te){H(!1);return}let v=((oe=Oe.current)==null?void 0:oe.getBoundingClientRect())??null,U=null,G=0;const Y=ae=>{var ye;rt.current=ae,(ye=Oe.current)==null||ye.style.setProperty("--bl-slider-pos",`${ae}%`),lt.current&&(lt.current.textContent=String(Math.round(ae)))},pe=ae=>{var ye;(!v||v.width<=0)&&(v=((ye=Oe.current)==null?void 0:ye.getBoundingClientRect())??null),!(!v||v.width<=0)&&(U=Math.max(2,Math.min(98,(ae.clientX-v.left)/v.width*100)),G===0&&(G=window.requestAnimationFrame(()=>{G=0,U!==null&&Y(U)})))},J=()=>{G!==0&&(window.cancelAnimationFrame(G),G=0);const ae=U??rt.current;Y(ae),q(ae),H(!1)};return window.addEventListener("mousemove",pe),window.addEventListener("mouseup",J),()=>{G!==0&&window.cancelAnimationFrame(G),window.removeEventListener("mousemove",pe),window.removeEventListener("mouseup",J)}},[V,te]),e.jsxs("div",{className:"bl-stage-enter flex-1 flex flex-col min-w-0 h-full relative z-10",children:[e.jsx(kn,{branches:s,baseRef:i,targetRef:d,compareSurface:u,changeSummary:m,onCompareSurfaceChange:n,viewMode:B,opacity:le,holdingOriginal:ne,picking:$e,pickedCount:zt.length,canPick:zs,onViewModeChange:z,onOpacityChange:re,onHoldingOriginalChange:D,onTogglePicking:Hs,onBaseChange:_,onTargetChange:L,onSwap:k,onReload:()=>ce(v=>v+1),onGoAnnotate:I,onOpenPrDraft:P,onBackToTree:F}),u==="code"?e.jsx(r.Suspense,{fallback:e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-xs",style:{color:"var(--muted)"},children:[e.jsx("div",{className:"bl-spinner"}),e.jsx("span",{children:"正在加载后端差异与 AI 总结…"})]}),children:e.jsx(pl,{baseRef:i,targetRef:d,baseLabel:ot,targetLabel:ct,changeSummary:m,displayMode:Ss,initialFilePath:Ns,onDisplayModeChange:c||wt!==void 0?ht:void 0})}):null,u==="matrix"?e.jsx(r.Suspense,{fallback:e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-xs",style:{color:"var(--muted)"},children:[e.jsx("div",{className:"bl-spinner"}),e.jsx("span",{children:"正在加载响应式矩阵…"})]}),children:e.jsx(hl,{branches:s,baseRef:i,targetRef:d,route:f,compareTargets:x,allRoutes:h,onJumpToViewport:Zs})}):null,u==="visual"?e.jsxs(e.Fragment,{children:[e.jsx(Mn,{route:f,onRouteChange:g,compareTargets:x,allRoutes:h,routeParams:b,onSaveRouteParams:j,mockAuthEnabled:S,mockAuthBusy:Be,onToggleMockAuth:w?()=>void Gs():void 0,canAutoLogin:A,autoLoginBusy:tt,onAutoLogin:M?()=>void Ys():void 0,liveDiffs:ut?[]:fe,activeDiffIdx:Re,baseUrl:Ne,targetUrl:Se,spotlightEnabled:st,aiExplainMode:Ts,syncEnabled:ie,hasSavedSession:y,isOnLoginScreen:$t,onFocusDiffSpot:pt,onToggleSpotlight:Is,onToggleAiExplain:Vs,onTriggerRescan:De,onToggleSync:()=>et(v=>!v),onClearSession:p}),Qs&&e.jsxs("div",{role:"status","data-testid":"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",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ze,{size:13,style:{color:"var(--accent)"},className:"shrink-0"}),e.jsxs("span",{className:"font-medium",style:{color:"var(--ink)"},children:["当前前端界面未发现明显视觉差异,检测到 ",Ot," 处后端变动"]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>Xe("plain"),className:"sheet-btn sheet-btn-primary text-xs py-1 px-2.5",children:"查看 AI 通俗总结"}),e.jsx("button",{type:"button",onClick:()=>Xe("code"),className:"sheet-btn text-xs py-1 px-2.5",children:"查看代码差异"})]})]}),e.jsx(Cn,{picking:$e,items:zt,onStopPicking:Ce,onRemoveItem:Fs,onClearAll:Os,onSendToCodex:Xs})]}):null,it?e.jsxs("div",{ref:St,"data-testid":"compare-visual-stage","data-stage-active":te?"true":"false","aria-hidden":te?void 0:"true",className:u==="visual"?"bl-compare-stage-body flex-1 min-h-0 relative overflow-hidden p-3 sm:p-4 flex flex-col":"hidden","data-compare-view-mode":B,children:[e.jsxs("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[e.jsx(fl,{viewMode:B,holdingOriginal:ne,sliderPos:Q,opacity:le,draggingSlider:V,viewport:N,branches:s,baseRef:i,targetRef:d,baseLabel:ot,targetLabel:ct,baseUrl:Ne,targetUrl:Se,baseFrameSrc:Bs,targetFrameSrc:Rs,onFrameLoadA:$s,onFrameLoadB:Ps,baseInst:de,targetInst:ue,sliderContainerRef:Oe,sliderPercentRef:lt,iframeARef:me,iframeBRef:xe,stageActive:te,onDragStart:()=>H(!0),onBaseChange:_,onTargetChange:L,onRetryStart:E,onBackToTree:F,onOpenLogs:K}),Ht&&!ke&&e.jsxs("div",{role:"status","data-testid":"spotlight-explain-guide",className:"bl-spotlight-guide-pill",children:[e.jsx("span",{className:"bl-picker-dot","aria-hidden":"true"}),e.jsx("span",{children:"悬停并点击任意红框查看 AI 对比讲解"}),e.jsx("button",{type:"button",onClick:Us,className:"bl-spotlight-guide-exit",children:"退出"})]})]}),e.jsx(Pn,{route:f,viewport:N,onViewportChange:C})]},"compare-visual-stage"):null,u==="visual"?e.jsx($n,{activeExplain:ke,baseLabel:ot,targetLabel:ct,totalDiffs:fe.length,currentIdx:ke?Math.max(0,fe.findIndex(v=>v.id===ke.spot.id)):Re,onClose:ft,onNavigate:Ds,onRetry:Ks,onOpenCodeDiff:n||a?Js:void 0}):null]})};export{jl as CompareStage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.bl-subbar{border-bottom:1px solid var(--hair);background:var(--bg)}[data-style=glass] .bl-subbar{background:#ffffff8a;backdrop-filter:blur(28px) saturate(200%);-webkit-backdrop-filter:blur(28px) saturate(200%);border-bottom:1px solid rgba(255,255,255,.68)}[data-style=glass][data-theme=dark] .bl-subbar{background:#1a1d268f;border-bottom-color:#ffffff1a}.bl-frame{border:1px solid var(--hair-strong);background:var(--surface);overflow:hidden;transition:box-shadow .32s var(--spring),transform .32s var(--spring)}.bl-frame-body,.bl-frame iframe{background:#fff}.bl-frame-primary{border:1px solid var(--rule)}[data-style=glass] .bl-frame{border-radius:20px;border:1px solid var(--glass-border);box-shadow:var(--glass-shadow)}.bl-frame-head{height:32px;padding:0 12px;border-bottom:1px solid var(--hair);background:var(--surface);color:var(--ink);font-size:11.5px}[data-style=glass] .bl-frame-head{height:42px;padding:0 16px;font-size:13.5px;font-weight:520;background:var(--glass-bg-strong);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px)}.bl-picker-toggle{display:inline-flex;align-items:center;gap:5px;padding:4px 10px;font-size:12.5px;font-weight:520;color:var(--ink);background:transparent;border:1px solid var(--hair-strong);border-radius:6px;transition:background .18s ease,border-color .18s ease,color .18s ease}.bl-picker-toggle:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}.bl-picker-toggle[data-active=true]{background:var(--accent);border-color:var(--accent);color:#fff}[data-style=glass] .bl-picker-toggle{border-radius:999px;padding:5px 12px;background:var(--glass-bg);border-color:var(--glass-border)}[data-style=glass] .bl-picker-toggle[data-active=true]{background:var(--accent);border-color:var(--accent);color:#fff;box-shadow:0 4px 14px color-mix(in srgb,var(--accent) 32%,transparent)}.bl-picker-shell{border-bottom:1px solid var(--hair);background:var(--surface)}[data-style=glass] .bl-picker-shell{background:#ffffff9e;backdrop-filter:blur(24px) saturate(180%);-webkit-backdrop-filter:blur(24px) saturate(180%);border-bottom-color:var(--glass-border)}[data-style=glass][data-theme=dark] .bl-picker-shell{background:#161922b8;border-bottom-color:#ffffff1a}.bl-picker-banner{background:var(--accent-soft);border-bottom:1px solid var(--hair)}@keyframes bl-picker-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.45;transform:scale(.82)}}.bl-picker-dot{width:7px;height:7px;border-radius:999px;background:var(--accent);flex-shrink:0;animation:bl-picker-pulse 1.4s ease-in-out infinite}.bl-picker-strip{display:flex;align-items:center;gap:6px;overflow-x:auto;scrollbar-width:thin;min-width:0}.bl-picker-card{display:inline-flex;align-items:center;gap:6px;padding:3px 8px;background:var(--bg);border:1px solid var(--hair-strong);border-radius:999px;min-width:0;max-width:100%;transition:border-color .15s ease,background .15s ease}.bl-picker-card[data-expanded=true]{border-color:var(--accent);background:var(--accent-soft)}[data-style=glass] .bl-picker-card{border-radius:999px;background:var(--glass-bg-strong);border:1px solid var(--glass-border);box-shadow:0 2px 10px #0f172a0d}[data-style=glass][data-theme=dark] .bl-picker-card{background:#1e222ec7;border-color:#ffffff1f;box-shadow:0 2px 12px #00000047}[data-style=glass] .bl-picker-card[data-expanded=true]{border-color:var(--accent)}.bl-picker-detail-drawer{background:var(--bg);border:1px solid var(--hair-strong);border-radius:8px}[data-style=glass] .bl-picker-detail-drawer{border-radius:12px;background:var(--glass-bg-strong);border-color:var(--glass-border)}.bl-picker-source-btn{color:var(--accent);background:var(--accent-soft);border:1px solid transparent;border-radius:5px;padding:1px 6px;max-width:100%;transition:border-color .15s ease,background .15s ease}.bl-picker-source-btn:hover{border-color:var(--accent)}.bl-picker-style-chip{font-size:10px;line-height:1.4;padding:1px 6px;border-radius:4px;background:var(--surface);color:var(--muted);border:1px solid var(--hair);max-width:170px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}[data-style=glass][data-theme=dark] .bl-picker-style-chip{background:#ffffff0f;border-color:#ffffff1a}.bl-route-catalog{background:var(--bg);border:1px solid var(--hair-strong);border-radius:10px;box-shadow:0 12px 32px #0f172a29}[data-style=glass] .bl-route-catalog{border-radius:16px;background:#fffffff0;backdrop-filter:blur(28px) saturate(190%);-webkit-backdrop-filter:blur(28px) saturate(190%);border:1px solid var(--glass-border);box-shadow:0 16px 40px #0f172a2e}[data-style=glass][data-theme=dark] .bl-route-catalog{background:#161a24eb;border-color:#ffffff24;box-shadow:0 16px 44px #0000007a}.bl-route-catalog-item{padding:7px 10px;border-radius:8px;border:1px solid transparent;transition:background .15s ease,border-color .15s ease}.bl-route-catalog-item:hover{background:var(--surface);border-color:var(--hair)}.bl-route-catalog-item[data-active=true]{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 40%,transparent)}.bl-mock-auth-btn{display:inline-flex;align-items:center;gap:5px;padding:2px 9px;border-radius:999px;font-size:11.5px;font-weight:500;color:var(--muted);background:transparent;border:1px solid var(--hair-strong);transition:background .15s ease,border-color .15s ease,color .15s ease}.bl-mock-auth-btn:hover:not(:disabled){color:var(--ink);border-color:var(--accent)}.bl-mock-auth-btn[data-active=true]{background:color-mix(in srgb,var(--accent) 16%,transparent);border-color:var(--accent);color:var(--accent);font-weight:600}.bl-surface-tabs{padding:2px;border-radius:8px;background:var(--surface);border:1px solid var(--hair-strong)}[data-style=glass] .bl-surface-tabs{border-radius:999px;background:var(--glass-bg);border-color:var(--glass-border)}.bl-surface-tab{display:inline-flex;align-items:center;gap:5px;padding:4px 10px;border-radius:6px;font-size:12.5px;font-weight:500;color:var(--muted);transition:background .16s ease,color .16s ease}[data-style=glass] .bl-surface-tab{border-radius:999px}.bl-surface-tab:hover{color:var(--ink)}.bl-surface-tab[data-active=true]{background:var(--accent-soft);color:var(--accent);font-weight:600}.bl-codediff-grid{display:grid;grid-template-columns:270px minmax(0,1fr) 360px;background:var(--bg)}.bl-codediff-pane{background:var(--bg)}.bl-codediff-nav{border-right:1px solid var(--hair)}.bl-codediff-explain{border-left:1px solid var(--hair)}[data-style=glass] .bl-codediff-nav,[data-style=glass] .bl-codediff-explain{background:var(--glass-bg)}@media(max-width:1120px){.bl-codediff-grid{grid-template-columns:1fr;grid-template-rows:minmax(180px,28vh) minmax(260px,1fr) minmax(220px,34vh)}.bl-codediff-nav{border-right:0;border-bottom:1px solid var(--hair)}.bl-codediff-explain{border-left:0;border-top:1px solid var(--hair)}}.bl-codediff-file{padding:7px 9px;border-radius:7px;border:1px solid transparent;transition:background .14s ease,border-color .14s ease}.bl-codediff-file:hover{background:var(--surface);border-color:var(--hair)}.bl-codediff-file[data-active=true]{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 42%,transparent)}.bl-diff-split-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);border-bottom:1px solid color-mix(in srgb,var(--hair) 45%,transparent)}.bl-diff-cell{display:flex;align-items:stretch;min-width:0;padding-right:10px}.bl-diff-split-row[data-wrap=false] .bl-diff-cell{overflow-x:auto}.bl-diff-code{min-width:0;flex:1}.bl-diff-cell-right{border-left:1px solid var(--hair)}.bl-diff-unified-row{display:flex;align-items:stretch;padding-right:12px;border-bottom:1px solid color-mix(in srgb,var(--hair) 40%,transparent)}.bl-diff-lineno{display:inline-block;width:42px;padding:0 8px 0 4px;text-align:right;color:var(--faint);-webkit-user-select:none;user-select:none;flex-shrink:0}.bl-diff-sign{display:inline-block;width:16px;text-align:center;-webkit-user-select:none;user-select:none;flex-shrink:0}.bl-explain-card{padding:10px 12px;border-radius:8px;background:var(--surface);border:1px solid var(--hair)}.bl-explain-card[data-active=true]{border-color:var(--accent);background:color-mix(in srgb,var(--accent-soft) 55%,var(--bg))}[data-style=glass] .bl-explain-card{border-radius:12px;background:var(--glass-bg-strong);border-color:var(--glass-border)}[data-style=glass] .bl-explain-card[data-active=true]{border-color:var(--accent)}.bl-matrix-table-wrap{border:1px solid var(--hair-strong);border-radius:10px;background:var(--bg)}[data-style=glass] .bl-matrix-table-wrap{border-radius:16px;border-color:var(--glass-border);background:var(--glass-bg)}.bl-matrix-th{background:var(--surface);border-bottom:1px solid var(--hair-strong);border-right:1px solid var(--hair)}.bl-matrix-th:last-child{border-right:0}.bl-matrix-rowhead{background:var(--surface);border-bottom:1px solid var(--hair);border-right:1px solid var(--hair-strong)}.bl-matrix-td{border-bottom:1px solid var(--hair);border-right:1px solid var(--hair)}.bl-matrix-td:last-child{border-right:0}.bl-matrix-cell-card{background:var(--bg);border:1px solid var(--hair-strong);border-radius:8px}[data-style=glass] .bl-matrix-cell-card{border-radius:12px;background:var(--glass-bg-strong);border-color:var(--glass-border)}.bl-plain-card{background:var(--bg);border:1px solid var(--hair-strong);border-radius:10px}[data-style=glass] .bl-plain-card{border-radius:14px;background:var(--glass-bg-strong);border-color:var(--glass-border)}.bl-handoff-banner{background:color-mix(in srgb,var(--accent-soft) 72%,var(--surface));border-bottom:1px solid color-mix(in srgb,var(--accent) 30%,var(--hair))}[data-style=glass] .bl-handoff-banner{background:color-mix(in srgb,var(--accent-soft) 65%,var(--glass-bg-strong));border-bottom-color:color-mix(in srgb,var(--accent) 28%,var(--glass-border))}@media(min-width:1320px){.bl-compare-toolbar-primary[data-has-surface-tabs=true]{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;column-gap:12px}.bl-compare-toolbar-primary[data-has-surface-tabs=true]>.bl-compare-refs{justify-self:start}.bl-compare-toolbar-primary[data-has-surface-tabs=true]>.bl-surface-tabs{justify-self:center}.bl-compare-toolbar-primary[data-has-surface-tabs=true]>.bl-compare-pr-btn{justify-self:end}}.bl-compare-toolbar-secondary{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;column-gap:12px;row-gap:6px;border-top:1px solid var(--hair)}.bl-compare-secondary-left{justify-self:start;min-width:0}.bl-compare-viewmodes{justify-self:center}.bl-compare-actions{justify-self:end;min-width:0}[data-style=glass] .bl-compare-toolbar .sheet-btn{height:28px;padding:0 11px;font-size:12px}.bl-split-grid{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}[data-host=harness-panel] .bl-split-grid{gap:10px}[data-host=harness-panel] .bl-compare-toolbar{padding-left:12px;padding-right:12px;gap:6px}[data-host=harness-panel] .bl-live-diff-bar,[data-host=harness-panel] .bl-codediff-topbar{padding-left:12px;padding-right:12px;gap:8px}[data-host=harness-panel] .bl-compare-stage-body{padding:10px 12px}[data-host=harness-panel] .bl-compare-ref-select{max-width:132px}[data-host=harness-panel] .bl-surface-tab{padding:3px 8px;font-size:12px}@media(max-width:1023px){.bl-split-grid{gap:10px}}@media(max-width:959px){.bl-compare-toolbar-secondary{grid-template-columns:auto auto minmax(0,1fr)}.bl-compare-viewmodes{grid-column:1;grid-row:1;justify-self:start}.bl-compare-secondary-left{grid-column:2;grid-row:1;justify-self:start}.bl-compare-onion-opacity{padding-left:10px;border-left:1px solid var(--hair-strong)}.bl-compare-actions{grid-column:3;grid-row:1;justify-self:end}}@media(max-width:720px){.bl-compare-toolbar{padding:6px 10px;gap:5px;min-height:0}.bl-compare-toolbar-secondary{padding-top:5px}.bl-live-diff-bar,.bl-codediff-topbar{padding:6px 10px;gap:6px;min-height:0}.bl-compare-stage-body{padding:8px 10px}.bl-compare-refs,.bl-compare-viewmodes,.bl-compare-actions{gap:6px;font-size:12px}.bl-compare-ref-select,[data-style=glass] .bl-compare-ref-select{max-width:98px;height:26px;padding:0 8px;font-size:11.5px}.bl-compare-toolbar .sheet-btn,[data-style=glass] .bl-compare-toolbar .sheet-btn{height:28px;padding:0 10px;font-size:11.5px}.bl-surface-tabs,[data-style=glass] .bl-surface-tabs{border-radius:12px;padding:2px;gap:2px}.bl-surface-tab{padding:3px 7px;font-size:11.5px}.bl-frame-head,[data-style=glass] .bl-frame-head{height:32px;padding:0 10px;font-size:12px}.bl-route-input{width:128px}.bl-viewport-ruler{margin-top:6px;padding-top:6px}.bl-plain-summary-inner{padding:12px 12px 24px}.bl-plain-card{min-width:0;overflow:hidden}.bl-codediff-grid{grid-template-columns:minmax(0,1fr)}}@media(max-width:680px){.bl-compare-toolbar-secondary{grid-template-columns:auto minmax(0,1fr)}.bl-compare-viewmodes{grid-column:1 / -1;grid-row:1;justify-self:center}.bl-compare-secondary-left{grid-column:1;grid-row:2;justify-self:start}.bl-compare-onion-opacity{padding-left:0;border-left:0}.bl-compare-actions{grid-column:2;grid-row:2;justify-self:end}}@media(max-width:560px){.bl-split-grid{grid-template-columns:1fr;gap:10px;overflow-y:auto}.bl-split-slot{min-height:240px}}.bl-ai-explain-toggle{display:inline-flex;align-items:center;gap:4px;padding:2px 9px;border-radius:6px;font-size:11.5px;font-weight:560;line-height:1.5;color:var(--ink);background:transparent;border:1px solid var(--hair-strong);cursor:pointer;white-space:nowrap;transition:background-color .16s ease,border-color .16s ease,color .16s ease,box-shadow .16s ease}.bl-ai-explain-toggle:hover{border-color:var(--accent);color:var(--accent);background:var(--accent-soft)}.bl-ai-explain-toggle[data-active=true]{background:var(--accent);border-color:var(--accent);color:#fff;box-shadow:0 2px 8px color-mix(in srgb,var(--accent) 30%,transparent)}[data-style=glass] .bl-ai-explain-toggle{border-radius:999px;padding:2px 10px;background:var(--glass-bg);border-color:var(--glass-border)}[data-style=glass] .bl-ai-explain-toggle:hover{border-color:var(--accent);color:var(--accent);background:var(--accent-soft)}[data-style=glass] .bl-ai-explain-toggle[data-active=true]{background:var(--accent);border-color:var(--accent);color:#fff;box-shadow:0 4px 14px color-mix(in srgb,var(--accent) 36%,transparent)}[data-style=glass][data-theme=dark] .bl-ai-explain-toggle{background:#1e222ec7;border-color:#ffffff24}[data-style=glass][data-theme=dark] .bl-ai-explain-toggle[data-active=true]{background:var(--accent);border-color:var(--accent);color:#fff}@keyframes bl-spotlight-pop-in{0%{opacity:0;transform:translateY(4px) scale(.985)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes bl-spotlight-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}.bl-spotlight-popover{position:fixed;z-index:190;width:min(372px,calc(100vw - 24px));max-height:min(480px,calc(100vh - 24px));display:flex;flex-direction:column;overflow:hidden;border-radius:8px;background:var(--bg);color:var(--ink);border:1px solid var(--rule);box-shadow:0 12px 32px #0f172a2e,0 2px 8px #0f172a14;animation:bl-spotlight-pop-in .18s var(--spring, cubic-bezier(.22, 1, .36, 1)) both}[data-theme=dark] .bl-spotlight-popover{border-color:#ecebe657;box-shadow:0 18px 44px #0000009e,0 2px 10px #0000006b}[data-style=glass] .bl-spotlight-popover{border-radius:16px;border:1px solid rgba(255,255,255,.92);background:linear-gradient(155deg,#fffffffa,#f8fafef7 58%,#fffffffb);backdrop-filter:blur(28px) saturate(185%);-webkit-backdrop-filter:blur(28px) saturate(185%);box-shadow:0 0 0 .5px #0f172a17,0 14px 34px -4px #0f172a2e,0 28px 60px -12px #142a563d,inset 0 1.5px .5px #fff}[data-style=glass][data-theme=dark] .bl-spotlight-popover{border-color:#ffffff2e;background:linear-gradient(155deg,#1c202cfb,#151822f9 58%,#191d29fb);box-shadow:0 0 0 .5px #000c,0 18px 46px -4px #000000c2,inset 0 1.5px .5px #ffffff29}.bl-spotlight-popover-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 12px 9px 14px;border-bottom:1px solid var(--hair)}.bl-spotlight-spot-badge{display:inline-flex;align-items:center;justify-content:center;min-width:24px;height:18px;padding:0 6px;border-radius:999px;font-size:10.5px;font-weight:700;color:#fff;background:var(--redline, #d70015);box-shadow:0 1px 4px #d7001547}.bl-spotlight-kind-pill{display:inline-flex;align-items:center;padding:1px 6px;border-radius:4px;font-size:10px;font-weight:600;line-height:1.5;background:var(--accent-soft);color:var(--accent)}[data-style=glass] .bl-spotlight-kind-pill{border-radius:999px}.bl-spotlight-kind-pill[data-tone=add]{background:var(--diff-add-bg, rgba(22, 163, 74, .14));color:var(--diff-add-ink, #15803d)}.bl-spotlight-kind-pill[data-tone=del]{background:var(--diff-del-bg, rgba(220, 38, 38, .12));color:var(--diff-del-ink, #dc2626)}.bl-spotlight-close-btn{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:6px;color:var(--muted);background:transparent;border:1px solid transparent;cursor:pointer;transition:color .14s ease,background-color .14s ease,border-color .14s ease}.bl-spotlight-close-btn:hover{color:var(--ink);background:var(--surface);border-color:var(--hair-strong)}[data-style=glass] .bl-spotlight-close-btn{border-radius:999px}.bl-spotlight-popover-meta{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:6px 14px;background:var(--surface);border-bottom:1px solid var(--hair)}[data-style=glass] .bl-spotlight-popover-meta{background:#0f172a08}[data-style=glass][data-theme=dark] .bl-spotlight-popover-meta{background:#ffffff0a;border-bottom-color:#ffffff17}.bl-spotlight-source-badge{display:inline-flex;align-items:center;padding:1px 6px;border-radius:4px;background:var(--accent-soft);color:var(--accent);font-weight:600}.bl-spotlight-source-badge[data-fallback=true]{background:var(--bg);color:var(--muted);border:1px solid var(--hair-strong);font-weight:500}.bl-spotlight-cached-badge{display:inline-flex;align-items:center;padding:1px 5px;border-radius:4px;background:var(--bg);color:var(--faint);border:1px solid var(--hair)}.bl-spotlight-skeleton{border-radius:7px;background:linear-gradient(90deg,var(--surface) 25%,color-mix(in srgb,var(--hair-strong) 55%,var(--surface)) 50%,var(--surface) 75%);background-size:200% 100%;animation:bl-spotlight-shimmer 1.3s ease-in-out infinite}.bl-spotlight-summary-box{padding:9px 11px;border-radius:7px;background:color-mix(in srgb,var(--accent-soft) 68%,var(--bg));border:1px solid color-mix(in srgb,var(--accent) 28%,var(--hair));border-left:3px solid var(--accent);color:var(--ink)}[data-style=glass] .bl-spotlight-summary-box{border-radius:10px}[data-style=glass][data-theme=dark] .bl-spotlight-summary-box{background:color-mix(in srgb,var(--accent) 16%,rgba(255,255,255,.03));border-color:color-mix(in srgb,var(--accent) 36%,rgba(255,255,255,.1));border-left-color:var(--accent)}.bl-spotlight-ab-card{padding:8px 9px;border-radius:7px;background:var(--surface);border:1px solid var(--hair);min-width:0}.bl-spotlight-ab-card[data-side=b]{background:color-mix(in srgb,var(--accent-soft) 36%,var(--bg));border-color:color-mix(in srgb,var(--accent) 28%,var(--hair))}[data-style=glass] .bl-spotlight-ab-card{border-radius:10px;background:#0f172a08}[data-style=glass][data-theme=dark] .bl-spotlight-ab-card{background:#ffffff0a;border-color:#ffffff1a}[data-style=glass][data-theme=dark] .bl-spotlight-ab-card[data-side=b]{background:color-mix(in srgb,var(--accent) 12%,rgba(255,255,255,.03));border-color:color-mix(in srgb,var(--accent) 34%,rgba(255,255,255,.1))}.bl-spotlight-swatch-chip{display:inline-flex;align-items:center;gap:4px;padding:1px 5px 1px 4px;border-radius:4px;font-size:10px;line-height:1.4;background:var(--bg);color:var(--muted);border:1px solid var(--hair-strong);max-width:100%}.bl-spotlight-swatch-dot{display:inline-block;width:11px;height:11px;border-radius:3px;flex-shrink:0;border:1px solid rgba(15,23,42,.24);box-shadow:inset 0 0 0 .5px #ffffff59}[data-theme=dark] .bl-spotlight-swatch-dot{border-color:#ffffff52}.bl-spotlight-token-chip{display:inline-flex;align-items:center;padding:1px 5px;border-radius:4px;font-size:10px;line-height:1.4;background:var(--bg);color:var(--muted);border:1px solid var(--hair);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.bl-spotlight-file-chip{display:inline-flex;align-items:center;padding:2px 7px;border-radius:5px;font-size:10.5px;color:var(--accent);background:var(--accent-soft);border:1px solid transparent;cursor:pointer;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:border-color .14s ease,background-color .14s ease}.bl-spotlight-file-chip:hover{border-color:var(--accent)}.bl-spotlight-popover-footer{display:flex;flex-shrink:0;align-items:center;justify-content:space-between;gap:8px;padding:8px 12px;background:var(--surface);border-top:1px solid var(--hair)}[data-style=glass] .bl-spotlight-popover-footer{background:#0f172a08}[data-style=glass][data-theme=dark] .bl-spotlight-popover-footer{background:#ffffff0a;border-top-color:#ffffff17}.bl-spotlight-footer-btn{display:inline-flex;align-items:center;gap:3px;padding:4px 8px;border-radius:6px;font-size:11px;font-weight:520;color:var(--ink);background:var(--bg);border:1px solid var(--hair-strong);cursor:pointer;white-space:nowrap;transition:border-color .14s ease,color .14s ease,background-color .14s ease}.bl-spotlight-footer-btn:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}.bl-spotlight-footer-btn-accent{background:var(--accent-soft);border-color:color-mix(in srgb,var(--accent) 42%,transparent);color:var(--accent);font-weight:600}.bl-spotlight-footer-btn-accent:hover:not(:disabled){background:var(--accent);border-color:var(--accent);color:#fff}[data-style=glass] .bl-spotlight-footer-btn{border-radius:999px}[data-style=glass][data-theme=dark] .bl-spotlight-footer-btn{background:#ffffff0f;border-color:#ffffff24}[data-style=glass][data-theme=dark] .bl-spotlight-footer-btn-accent{background:color-mix(in srgb,var(--accent) 22%,rgba(255,255,255,.04));border-color:color-mix(in srgb,var(--accent) 52%,transparent);color:var(--accent)}[data-style=glass][data-theme=dark] .bl-spotlight-footer-btn-accent:hover:not(:disabled){background:var(--accent);border-color:var(--accent);color:#fff}.bl-spotlight-guide-pill{position:absolute;bottom:14px;left:50%;transform:translate(-50%);z-index:25;display:inline-flex;align-items:center;gap:8px;max-width:calc(100% - 24px);padding:5px 10px 5px 12px;border-radius:999px;font-size:11.5px;font-weight:540;color:var(--ink);background:var(--bg);border:1px solid var(--rule);box-shadow:0 8px 24px #0f172a24;white-space:nowrap}[data-theme=dark] .bl-spotlight-guide-pill{border-color:#ecebe657;box-shadow:0 10px 28px #0000008a}[data-style=glass] .bl-spotlight-guide-pill{background:#fffffff5;border-color:#ffffffeb;backdrop-filter:blur(24px) saturate(180%);-webkit-backdrop-filter:blur(24px) saturate(180%);box-shadow:0 0 0 .5px #0f172a14,0 10px 28px -4px #0f172a2e,inset 0 1px .5px #fff}[data-style=glass][data-theme=dark] .bl-spotlight-guide-pill{background:#1a1e2af5;border-color:#ffffff29;box-shadow:0 0 0 .5px #000000b8,0 12px 30px #000000a3,inset 0 1px .5px #ffffff29}.bl-spotlight-guide-exit{padding:1px 7px;border-radius:999px;font-size:10.5px;font-weight:560;color:var(--muted);background:var(--surface);border:1px solid var(--hair-strong);cursor:pointer;transition:color .14s ease,border-color .14s ease}.bl-spotlight-guide-exit:hover{color:var(--ink);border-color:var(--accent)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,j as s}from"./vendor-react-CIotE-6Q.js";import{k as M,f as $}from"./index-CuRBE0Be.js";import{s as J,l as K,T as P,p as W,a6 as X,C as q,a as F,J as Q}from"./vendor-icons-BeN0on9X.js";const V={node:{label:"Node.js 运行时",tier:"核心"},git:{label:"Git 版本控制",tier:"核心"},packageManager:{label:"包管理器",tier:"核心"},chrome:{label:"Chrome / Chromium",tier:"可选",settingsTab:"env",settingsLabel:"本机环境"},codex:{label:"Codex CLI",tier:"可选",settingsTab:"agent",settingsLabel:"Agent 设置"},ai:{label:"AI 模型配置",tier:"可选",settingsTab:"ai",settingsLabel:"AI 设置"},repo:{label:"Git 工作仓库",tier:"可选"}},Y={ok:"就绪",warn:"可选缺项",missing:"必需缺失"};function Z(r){if(!r)return!1;try{return new URL(r).protocol==="https:"}catch{return!1}}function O(r){switch(r){case"darwin":return"macOS";case"win32":return"Windows";case"linux":return"Linux";default:return r||"未知系统"}}const as=({report:r,loading:g,error:E,onRefresh:d,enabled:h=!0,compact:j=!1,currentSettingsTab:I,onOpenSettingsTab:u,title:S="本机环境自检",subtitle:v})=>{const o=r!==void 0||d!==void 0,[A,R]=t.useState(null),[z,N]=t.useState(!1),[U,y]=t.useState(null),[D,C]=t.useState(null),i=t.useRef(!0),c=t.useRef(null),w=t.useRef(!1);t.useEffect(()=>(i.current=!0,()=>{i.current=!1,c.current!==null&&window.clearTimeout(c.current)}),[]);const m=t.useCallback(async()=>{N(!0),y(null);try{const e=await M.getDoctor();if(!i.current)return;R(e)}catch(e){if(!i.current)return;y(e instanceof Error?e.message:String(e))}finally{i.current&&N(!1)}},[]);t.useEffect(()=>{o||!h||w.current||(w.current=!0,m())},[o,h,m]);const n=o?r??null:A,x=o?!!g:z,f=o?E??null:U,k=t.useCallback(()=>{d?d():m()},[d,m]),B=t.useCallback(async(e,a)=>{!await $(a)||!i.current||(C(e),c.current!==null&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{i.current&&C(null)},1800))},[]),l=(n==null?void 0:n.checks)??[],G=l.filter(e=>e.status==="ok").length,b=l.filter(e=>e.status==="missing").length,T=l.filter(e=>e.status==="warn").length;return s.jsxs("section",{"data-testid":"doctor-checklist",className:"space-y-2.5",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[s.jsx("h2",{className:j?"text-[13px] font-semibold":"text-[15.5px] font-semibold",children:S}),l.length>0&&s.jsxs("span",{className:"mono text-[11px] px-2 py-0.5 rounded-full",style:{background:"var(--surface)",color:"var(--muted)",border:"1px solid var(--hair)"},children:[G,"/",l.length," 就绪"]}),b>0&&s.jsxs("span",{className:"bl-status-badge","data-status":"missing",children:[b," 项核心缺失"]}),b===0&&T>0&&s.jsxs("span",{className:"bl-status-badge","data-status":"warn",children:[T," 项可选待配"]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[(n==null?void 0:n.platform)&&s.jsxs("span",{className:"mono text-[11px]",style:{color:"var(--faint)"},children:[O(n.platform),n.version?` · v${n.version}`:""]}),s.jsxs("button",{type:"button",onClick:k,disabled:x,"data-testid":"doctor-refresh-btn",className:"bl-doctor-mini-btn disabled:opacity-50",children:[s.jsx(J,{size:12,className:x?"animate-spin":void 0}),s.jsx("span",{children:x?"检测中…":"重新检测"})]})]})]}),v&&s.jsx("p",{className:"text-[11.5px] leading-snug m-0",style:{color:"var(--muted)"},children:v})]}),f&&s.jsxs("div",{role:"alert",className:"px-3 py-2 text-xs rounded-lg flex items-center justify-between gap-2",style:{background:"var(--bl-missing-bg)",color:"var(--bl-missing-ink)",border:"1px solid var(--bl-missing-border)"},children:[s.jsxs("span",{className:"break-all",children:["环境检查失败:",f]}),s.jsx("button",{type:"button",onClick:k,className:"underline shrink-0",children:"重试"})]}),x&&l.length===0?s.jsxs("div",{className:"py-8 flex items-center justify-center gap-2.5 text-xs",style:{color:"var(--muted)"},children:[s.jsx("div",{className:"bl-spinner"}),s.jsx("span",{children:"正在探测 Node.js、Git、Chrome 与 Agent 环境…"})]}):l.length===0&&!f?s.jsx("div",{className:"py-6 text-center text-xs",style:{color:"var(--faint)"},children:"暂未获取到环境检查结果,点击「重新检测」开始探测。"}):s.jsx("ul",{className:"bl-doctor-list m-0 p-0 list-none",children:l.map(e=>{const a=V[e.id]??{label:e.id,tier:"可选"},p=Z(e.docsUrl)?e.docsUrl:null,_=!!(u&&a.settingsTab)&&a.settingsTab!==I,L=D===e.id,H=e.status==="ok"?K:e.status==="warn"?P:W;return s.jsx("li",{"data-doctor-check":e.id,"data-doctor-status":e.status,"data-compact":j?"true":void 0,className:"bl-doctor-row",children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[s.jsx(H,{size:14,className:"shrink-0",style:{color:e.status==="ok"?"var(--bl-ok-ink)":e.status==="warn"?"var(--bl-warn-ink)":"var(--bl-missing-ink)"}}),s.jsx("span",{className:"font-semibold text-[12.5px]",style:{color:"var(--ink)"},children:a.label}),s.jsx("span",{className:"mono text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface)",color:"var(--faint)",border:"1px solid var(--hair)"},children:a.tier})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[_&&a.settingsTab&&s.jsxs("button",{type:"button",onClick:()=>u==null?void 0:u(a.settingsTab),"data-doctor-settings":a.settingsTab,className:"bl-doctor-mini-btn",children:[s.jsx(X,{size:11}),s.jsx("span",{children:a.settingsLabel||"去设置"})]}),s.jsx("span",{className:"bl-status-badge shrink-0","data-status":e.status,children:Y[e.status]})]})]}),s.jsx("p",{className:"text-[11.5px] leading-snug break-words m-0",style:{color:"var(--muted)"},children:e.detail}),(e.fixCommand||p)&&s.jsxs("div",{className:"pt-1 flex items-center gap-2 flex-wrap",children:[e.fixCommand&&s.jsxs("div",{className:"bl-doctor-cmd",children:[s.jsx("code",{className:"truncate max-w-[260px] sm:max-w-[340px]",children:e.fixCommand}),s.jsxs("button",{type:"button",onClick:()=>void B(e.id,e.fixCommand),"data-copy-command":e.id,className:"bl-doctor-mini-btn",title:`复制命令:${e.fixCommand}`,children:[L?s.jsx(q,{size:11}):s.jsx(F,{size:11}),s.jsx("span",{children:L?"已复制":"复制"})]})]}),p&&s.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer","data-doctor-docs":e.id,className:"bl-doctor-mini-btn no-underline",children:[s.jsx("span",{children:"安装指引"}),s.jsx(Q,{size:11})]})]})]})},e.id)})})]})};export{as as D,O as f,Z as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as c,j as e,R as Ve}from"./vendor-react-CIotE-6Q.js";import{k as ce,f as Be,S as Fe}from"./index-CuRBE0Be.js";import{L as Ke}from"./LiquidSelect-BcHivJrw.js";import{a3 as Ue,V as Ge,X as qe,a7 as Qe,B as Ae,b as Je,c as Ye,C as oe,a as de,a5 as Xe,h as Ze,a8 as et,e as tt,a9 as st,aa as nt}from"./vendor-icons-BeN0on9X.js";const Se={dsh:{label:"DSH 对话",badge:"DSH"},codex:{label:"Codex 会话",badge:"Codex"},"branch-lens-task":{label:"BranchLens 任务",badge:"任务"},git:{label:"Git 记录",badge:"Git"}},at={input:{label:"输入"},model:{label:"模型"},tool:{label:"工具"}},ue={system:{label:"系统"},user:{label:"用户"},thinking:{label:"思考"},assistant:{label:"助手"},tool_call:{label:"工具调用"},tool_result:{label:"工具结果"},commit:{label:"提交"}},rt={ok:"正常",error:"失败",running:"进行中",unknown:"未知"};function f(a){return typeof a=="number"&&Number.isFinite(a)}function E(a){if(!f(a)||a<0)return null;if(a<1e3)return`${Math.round(a)} ms`;if(a<6e4)return`${(a/1e3).toFixed(2)} s`;const h=Math.floor(a/6e4),i=a%6e4/1e3;return`${h}m ${i.toFixed(1)}s`}function y(a){return!f(a)||a<0?null:Math.round(a).toLocaleString("en-US")}function Ie(a){return!f(a)||a<0?null:`${a.toFixed(1)} tok/s`}function Ce(a){if(!a)return null;const h=Date.parse(a);if(Number.isNaN(h))return a;const i=new Date(h),o=i.getFullYear(),m=String(i.getMonth()+1).padStart(2,"0"),v=String(i.getDate()).padStart(2,"0"),w=String(i.getHours()).padStart(2,"0"),n=String(i.getMinutes()).padStart(2,"0"),b=String(i.getSeconds()).padStart(2,"0");return`${o}-${m}-${v} ${w}:${n}:${b}`}function it(a){return a?f(a.inputTokens)||f(a.outputTokens)||f(a.cacheReadTokens)||f(a.cacheWriteTokens)||f(a.reasoningTokens)||f(a.totalTokens):!1}function lt(a){return!!(a.startedAt||f(a.durationMs)||f(a.ttftMs)||f(a.generationMs)||f(a.tps))}function ct(a){if(!a)return"";const h=a.trim();if(!h)return"";if(h.startsWith("{")||h.startsWith("["))try{return JSON.stringify(JSON.parse(h),null,2)}catch{return a}return a}function ot(a,h){return h?[a.title,a.summary,a.previewText,a.thinkingText,a.toolName,a.toolArgs,a.toolOutput,a.model].some(o=>typeof o=="string"&&o.toLowerCase().includes(h)):!0}const U=1.6;function dt(a,h){const i=h==="call"?a.filter(n=>n.kind!=="system"):a,o={input:[],model:[],tool:[]},m=[];if(i.length===0)return{steps:i,blocksByLane:o,degradedToEven:!1,turnMarkers:m};if(h==="turn"){const n=[],b=new Map;for(const j of i){const k=b.get(j.turnIndex);k?k.push(j):(n.push(j.turnIndex),b.set(j.turnIndex,[j]))}const u=100/n.length;return n.forEach((j,k)=>{const g=k*u;m.push({turnIndex:j,leftPct:g,widthPct:u});const R=b.get(j)??[],z=Math.min(.6,u*.06),Q=Math.max(.5,u-z*2)/Math.max(1,R.length);R.forEach((A,J)=>{const D=Math.max(U,Q*.88),O=Math.min(100-D,g+z+J*Q);o[A.lane].push({step:A,leftPct:O,widthPct:Math.min(D,100-O)})})}),{steps:i,blocksByLane:o,degradedToEven:!1,turnMarkers:m}}if(h==="call"){const n=100/i.length;return i.forEach((b,u)=>{const j=Math.max(U,Math.min(n*.86,100)),k=Math.min(100-j,u*n+n*.06);o[b.lane].push({step:b,leftPct:k,widthPct:j})}),{steps:i,blocksByLane:o,degradedToEven:!1,turnMarkers:m}}let v=!1,w=0;for(const n of i){const b=f(n.offsetMs)&&n.offsetMs>=0?n.offsetMs:0,u=f(n.durationMs)&&n.durationMs>0?n.durationMs:0;u>0&&(v=!0),b+u>w&&(w=b+u)}if(!v||w<=0){const n=100/i.length;return i.forEach((b,u)=>{const j=Math.max(U,Math.min(n*.86,100)),k=Math.min(100-j,u*n+n*.06);o[b.lane].push({step:b,leftPct:k,widthPct:j})}),{steps:i,blocksByLane:o,degradedToEven:!0,turnMarkers:m}}for(const n of i){const b=f(n.offsetMs)&&n.offsetMs>=0?n.offsetMs:0,u=f(n.durationMs)&&n.durationMs>0?n.durationMs:0,j=b/w*100,k=u>0?u/w*100:U,g=Math.min(100,Math.max(U,k)),R=Math.max(0,Math.min(100-g,j));o[n.lane].push({step:n,leftPct:R,widthPct:g})}return{steps:i,blocksByLane:o,degradedToEven:!1,turnMarkers:m}}function ut(a){const h=[],i=new Map;for(const o of a){let m=i.get(o.turnIndex);m||(m={turnIndex:o.turnIndex,steps:[]},i.set(o.turnIndex,m),h.push(m)),m.steps.push(o)}return h}const ht=["input","model","tool"],mt=80,Ee=28,he=34,q=600,Re=12;function $e(a,h){const i=a.length-1;if(i<=0||h<=0)return 0;let o=0,m=i-1;for(;o<m;){const v=o+m+1>>1;a[v]<=h?o=v:m=v-1}return o}function me(a,h,i){const o=a.length-1;if(o<=0)return{start:0,end:0};const m=Math.max(0,h),v=i>0?i:q,w=$e(a,m),n=$e(a,m+v);return{start:Math.max(0,w-Re),end:Math.min(o,n+1+Re)}}const xt=({kind:a})=>{switch(a){case"system":return e.jsx(nt,{size:13,className:"bl-tr-step-icon","aria-hidden":"true"});case"user":return e.jsx(st,{size:13,className:"bl-tr-step-icon","aria-hidden":"true"});case"thinking":return e.jsx(Ae,{size:13,className:"bl-tr-step-icon","aria-hidden":"true"});case"assistant":return e.jsx(tt,{size:13,className:"bl-tr-step-icon","aria-hidden":"true"});case"tool_call":return e.jsx(et,{size:13,className:"bl-tr-step-icon","aria-hidden":"true"});case"tool_result":return e.jsx(Ze,{size:13,className:"bl-tr-step-icon","aria-hidden":"true"});case"commit":return e.jsx(Xe,{size:13,className:"bl-tr-step-icon","aria-hidden":"true"})}};function G(a){return`${a.source}::${a.id}`}const kt=({mode:a,repoKey:h,target:i=null,onTargetChange:o,onBackToCanvas:m,taskId:v,compact:w=!1})=>{var ge,Te,we,Me;const[n,b]=c.useState(null),[u,j]=c.useState([]),[k,g]=c.useState(!0),[R,z]=c.useState(null),[S,Q]=c.useState("duration"),[A,J]=c.useState(""),[D,O]=c.useState(null),[_,_e]=c.useState("overview"),[Y,se]=c.useState(!1),[P,xe]=c.useState(null),W=c.useRef(0),V=c.useRef(null),ne=c.useRef(new Map),F=c.useRef(0),[ae,Le]=c.useState(q),pe=i==null?void 0:i.source,K=i==null?void 0:i.sessionId,fe=i==null?void 0:i.taskId,be=i==null?void 0:i.nodeId,X=i==null?void 0:i.turnIndex,re=c.useCallback(async()=>{var l;const t=++W.current;g(!0),z(null);try{const r=a==="task"?v?await ce.getTaskTrace(v):{repoPath:"",trace:null,sessions:[]}:await ce.getChronicleTrace({source:pe,sessionId:K,taskId:fe,nodeId:be,turnIndex:X});if(t!==W.current)return;b(r.trace??null),j(Array.isArray(r.sessions)?r.sessions:[]);const d=((l=r.trace)==null?void 0:l.steps)??[],x=typeof r.focusTurnIndex=="number"?r.focusTurnIndex:typeof X=="number"?X:void 0;let p;x!==void 0&&(p=d.find(I=>I.turnIndex===x)),p||(p=d[0]),O((p==null?void 0:p.id)??null),se(!1),g(!1)}catch(r){if(t!==W.current)return;z(r instanceof Error?r.message:String(r)),g(!1)}},[a,v,pe,K,fe,be,X]);c.useEffect(()=>{re()},[re,h]),c.useEffect(()=>()=>{F.current!==0&&window.clearTimeout(F.current)},[]);const $=c.useDeferredValue(A).trim().toLowerCase(),L=c.useMemo(()=>dt((n==null?void 0:n.steps)??[],S),[n==null?void 0:n.steps,S]),T=c.useMemo(()=>$?L.steps.filter(t=>ot(t,$)):L.steps,[L.steps,$]),je=c.useMemo(()=>$?new Set(T.map(t=>t.id)):null,[T,$]),Z=c.useMemo(()=>ut(T),[T]),C=T.length>mt,N=c.useMemo(()=>{const t=[],l=new Map;let r=0;const d=[0];for(const x of Z){t.push({kind:"turn-head",key:`turn-${x.turnIndex}`,turnIndex:x.turnIndex,stepCount:x.steps.length,height:Ee}),r+=Ee,d.push(r);for(const p of x.steps)l.set(p.id,{top:r,height:he}),t.push({kind:"step",key:p.id,step:p,height:he}),r+=he,d.push(r)}return{rows:t,offsets:d,totalHeight:r,stepOffsetById:l}},[Z]),H=`${(n==null?void 0:n.id)??""}::${S}::${$}::${N.rows.length}::${ae}`,[ee,Ne]=c.useState({key:"",start:0,end:0}),B=c.useMemo(()=>C?ee.key===H?{start:Math.min(ee.start,N.rows.length),end:Math.min(ee.end,N.rows.length)}:me(N.offsets,0,ae):{start:0,end:N.rows.length},[C,ee,H,N,ae]);c.useEffect(()=>{if(k||!n||n.steps.length===0)return;const t=V.current;if(!t)return;const l=()=>{const d=t.clientHeight>0?t.clientHeight:q;Le(x=>Math.abs(x-d)>=4?d:x)};if(l(),typeof ResizeObserver>"u")return;const r=new ResizeObserver(l);return r.observe(t),()=>r.disconnect()},[k,n]),c.useEffect(()=>{V.current&&(V.current.scrollTop=0)},[n==null?void 0:n.id,S,$]);const He=c.useCallback(()=>{if(!C)return;const t=V.current;if(!t)return;const l=t.clientHeight>0?t.clientHeight:q,r=me(N.offsets,t.scrollTop,l);Ne(d=>d.key===H&&d.start===r.start&&d.end===r.end?d:{key:H,start:r.start,end:r.end})},[C,N.offsets,H]),s=c.useMemo(()=>{const t=(n==null?void 0:n.steps)??[];if(D){const l=t.find(r=>r.id===D);if(l)return l}return T[0]??t[0]??null},[n==null?void 0:n.steps,D,T]);c.useEffect(()=>{se(!1)},[s==null?void 0:s.id]);const te=c.useCallback((t,l=!1)=>{if(O(t),!l)return;const r=ne.current.get(t);if(r&&typeof r.scrollIntoView=="function"){r.scrollIntoView({block:"nearest",behavior:"smooth"});return}if(C){const d=V.current,x=N.stepOffsetById.get(t);if(d&&x){const p=d.clientHeight>0?d.clientHeight:q,I=Math.max(0,x.top-Math.floor(p/2));d.scrollTop=I;const M=me(N.offsets,I,p);Ne({key:H,start:M.start,end:M.end})}}},[C,N,H]),ze=c.useCallback(t=>{if(t.key!=="ArrowDown"&&t.key!=="ArrowUp"||T.length===0)return;t.preventDefault();const l=T.findIndex(p=>p.id===(s==null?void 0:s.id)),r=t.key==="ArrowDown"?1:-1,d=l===-1?0:Math.max(0,Math.min(T.length-1,l+r)),x=T[d];x&&te(x.id,!0)},[T,s==null?void 0:s.id,te]),ie=c.useCallback(async(t,l)=>{const r=await Be(l);xe(r?t:`${t}:failed`),F.current!==0&&window.clearTimeout(F.current),F.current=window.setTimeout(()=>xe(null),1800)},[]),De=c.useMemo(()=>u.map(t=>{var l;return{value:G(t),label:`[${((l=Se[t.source])==null?void 0:l.badge)??t.source}] ${t.title}`,hint:`${t.turnCount} 轮`}}),[u]),Oe=c.useMemo(()=>{if(u.length===0)return"";if(n){const t=u.find(l=>n.sessionId&&l.id===n.sessionId&&l.source===n.source||n.taskId&&l.taskId===n.taskId||l.id===n.id&&l.source===n.source);if(t)return G(t)}if(K){const t=u.find(l=>l.id===K);if(t)return G(t)}return G(u[0])},[u,n,K]),Pe=c.useCallback(t=>{const l=u.find(d=>G(d)===t);if(!l)return;const r={source:l.source,sessionId:l.source==="branch-lens-task"?void 0:l.id,taskId:l.taskId??(l.source==="branch-lens-task"?l.id:void 0)};o==null||o(r),o||(async()=>{var x,p,I;const d=++W.current;g(!0);try{const M=await ce.getChronicleTrace(r);if(d!==W.current)return;b(M.trace??null),j(Array.isArray(M.sessions)?M.sessions:u),O(((I=(p=(x=M.trace)==null?void 0:x.steps)==null?void 0:p[0])==null?void 0:I.id)??null),g(!1)}catch(M){if(d!==W.current)return;z(M instanceof Error?M.message:String(M)),g(!1)}})()},[o,u]),ke=E(n==null?void 0:n.summary.totalDurationMs),ve=y((ge=n==null?void 0:n.summary.tokens)==null?void 0:ge.totalTokens),le=c.useMemo(()=>_==="raw"?ct(s==null?void 0:s.rawPayload):"",[_,s==null?void 0:s.rawPayload]),ye=t=>{const l=(s==null?void 0:s.id)===t.id,r=E(t.durationMs),d=t.status==="error"||f(t.exitCode)&&t.exitCode!==0;return e.jsxs("button",{ref:x=>{x?ne.current.set(t.id,x):ne.current.delete(t.id)},type:"button",role:"option","aria-selected":l,"data-testid":`trace-step-item-${t.id}`,"data-step-id":t.id,"data-lane":t.lane,"data-status":t.status,"data-selected":l?"true":"false",onClick:()=>te(t.id,!1),className:"bl-tr-step-item",children:[e.jsx(xt,{kind:t.kind}),e.jsx("span",{className:"bl-tr-step-title truncate",title:t.title,children:t.title}),e.jsxs("span",{className:"bl-tr-step-right mono shrink-0",children:[d&&e.jsx("span",{className:"bl-tr-err-tag",children:f(t.exitCode)?`exit ${t.exitCode}`:"错误"}),r&&e.jsx("span",{className:"bl-tr-step-dur",children:r})]})]},t.id)},We=()=>{if(!n)return null;const t=[];return n.summary.turnCount>0&&t.push({key:"turns",label:`${n.summary.turnCount} 轮`}),n.summary.stepCount>0&&t.push({key:"steps",label:`${n.summary.stepCount} 步`}),ke&&t.push({key:"dur",label:ke}),ve&&t.push({key:"tok",label:`${ve} tok`}),n.summary.errorCount>0&&t.push({key:"err",label:`${n.summary.errorCount} 错误`,tone:"error"}),t.length===0?null:e.jsx("div",{className:"bl-tr-metrics mono","data-testid":"trace-summary-metrics",children:t.map((l,r)=>e.jsxs(Ve.Fragment,{children:[r>0&&e.jsx("span",{className:"bl-tr-sep","aria-hidden":"true",children:"·"}),e.jsx("span",{"data-tone":l.tone,children:l.label})]},l.key))})};return e.jsxs("div",{className:"bl-tr-root","data-testid":"execution-trace-view","data-compact":w?"true":"false","data-mode":a,children:[e.jsxs("div",{className:"bl-tr-top",children:[e.jsxs("div",{className:"bl-tr-controls",children:[e.jsxs("div",{className:"bl-tr-controls-left",children:[m&&e.jsxs("button",{type:"button",onClick:m,"data-testid":"trace-back-to-canvas",className:"bl-pill-action bl-tr-back-btn",title:"返回开发历程画布",children:[e.jsx(Ue,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:"画布"})]}),a==="chronicle"&&u.length>0&&e.jsx(Ke,{ariaLabel:"选择执行轨迹会话",testId:"trace-session-select",value:Oe,options:De,minMenuWidth:240,onChange:Pe,className:"bl-tr-session-select"}),e.jsx("div",{className:"bl-tr-mode-switch",role:"tablist","aria-label":"轨迹时间轴视角",children:[{id:"duration",label:"时长"},{id:"turn",label:"轮次"},{id:"call",label:"调用"}].map(t=>e.jsx("button",{type:"button",role:"tab","aria-selected":S===t.id,"data-testid":`trace-mode-${t.id}`,"data-active":S===t.id?"true":"false",onClick:()=>Q(t.id),className:"bl-tr-switch-btn",children:t.label},t.id))})]}),e.jsxs("div",{className:"bl-tr-controls-right",children:[e.jsxs("div",{className:"bl-tr-search","data-active":$?"true":"false",children:[e.jsx(Ge,{size:12,className:"bl-tr-search-icon","aria-hidden":"true"}),e.jsx("input",{type:"text",value:A,onChange:t=>J(t.target.value),placeholder:"搜索步骤 / 工具 / 内容…","aria-label":"搜索执行轨迹步骤","data-testid":"trace-search-input",className:"bl-tr-search-input"}),A&&e.jsx("button",{type:"button",onClick:()=>J(""),"aria-label":"清空轨迹搜索","data-testid":"trace-search-clear",className:"bl-tr-search-clear",children:e.jsx(qe,{size:11})})]}),We()]})]}),(n==null?void 0:n.emptyReason)&&e.jsx("div",{className:"bl-tr-notice","data-testid":"trace-empty-reason-banner",role:"status",children:e.jsx("span",{children:n.emptyReason})}),(n==null?void 0:n.truncated)&&e.jsx("div",{className:"bl-tr-notice","data-tone":"subtle",children:e.jsx("span",{children:"日志步骤较多,已展示关键截断片段。"})}),!k&&!R&&n&&L.steps.length>0&&e.jsxs("div",{className:"bl-tr-waterfall","data-testid":"trace-waterfall","data-timeline-mode":S,children:[S==="duration"&&L.degradedToEven&&e.jsx("div",{className:"bl-tr-waterfall-hint","data-testid":"trace-duration-degraded-hint",children:"当前日志未记录精细耗时,已按执行顺序等宽展示"}),e.jsx("div",{className:"bl-tr-waterfall-lanes",children:ht.map(t=>{const l=L.blocksByLane[t];return e.jsxs("div",{className:"bl-tr-lane-row","data-lane":t,children:[e.jsx("span",{className:"bl-tr-lane-label",children:at[t].label}),e.jsxs("div",{className:"bl-tr-lane-track",children:[S==="turn"&&L.turnMarkers.map(r=>e.jsx("span",{className:"bl-tr-turn-slot-bg",style:{left:`${r.leftPct}%`,width:`${r.widthPct}%`},"aria-hidden":"true"},`tm-${t}-${r.turnIndex}`)),l.map(r=>{var I;const d=(s==null?void 0:s.id)===r.step.id,x=!!(je&&!je.has(r.step.id)),p=E(r.step.durationMs);return e.jsx("button",{type:"button","data-testid":`trace-waterfall-block-${r.step.id}`,"data-step-id":r.step.id,"data-lane":r.step.lane,"data-status":r.step.status,"data-selected":d?"true":"false","data-dimmed":x?"true":"false",onClick:()=>te(r.step.id,!0),className:"bl-tr-wf-block",style:{left:`${r.leftPct}%`,width:`${r.widthPct}%`},title:`${((I=ue[r.step.kind])==null?void 0:I.label)??r.step.kind}:${r.step.title}${p?` (${p})`:""}`,"aria-label":`${r.step.title}${p?`,耗时 ${p}`:""}`},r.step.id)})]})]},t)})})]})]}),k?e.jsxs("div",{className:"bl-tr-empty","data-testid":"trace-loading",children:[e.jsx("div",{className:"bl-spinner"}),e.jsx("span",{children:"正在加载执行轨迹…"})]}):R?e.jsxs("div",{className:"bl-tr-empty","data-testid":"trace-error",children:[e.jsx(Qe,{size:18,style:{color:"var(--accent)"}}),e.jsx("div",{className:"font-medium",children:"加载执行轨迹失败"}),e.jsx("div",{className:"text-[12px] max-w-md text-center",style:{color:"var(--muted)"},children:R}),e.jsx("button",{type:"button",onClick:()=>void re(),className:"sheet-btn",children:"重试"})]}):!n||n.steps.length===0?e.jsxs("div",{className:"bl-tr-empty","data-testid":"trace-empty",children:[e.jsx("div",{className:"text-[13.5px] font-medium",children:(n==null?void 0:n.emptyReason)||"当前尚无关联的本地执行轨迹"}),e.jsx("p",{className:"text-[12px] max-w-md text-center leading-relaxed",style:{color:"var(--muted)"},children:"枝镜会自动读取本机关联的 DSH / Codex 对话会话与 BranchLens 任务执行日志,无需额外配置。"})]}):e.jsxs("div",{className:"bl-tr-body",children:[e.jsx("div",{ref:V,className:"bl-tr-step-list","data-testid":"trace-step-list","data-virtualized":C?"true":"false",role:"listbox","aria-label":"执行步骤列表",tabIndex:0,onKeyDown:ze,onScroll:C?He:void 0,children:Z.length===0?e.jsxs("div",{className:"bl-tr-list-empty",children:["没有匹配「",A.trim(),"」的步骤"]}):C?e.jsxs("div",{className:"flex flex-col gap-0.5 shrink-0",children:[N.offsets[B.start]>0&&e.jsx("div",{"aria-hidden":"true","data-virtual-spacer":"top",style:{height:N.offsets[B.start],flexShrink:0}}),N.rows.slice(B.start,B.end).map(t=>t.kind==="turn-head"?e.jsxs("div",{className:"bl-tr-turn-head mono",children:[e.jsx("span",{children:t.turnIndex>0?`#${t.turnIndex} 轮`:"会话前置"}),e.jsxs("span",{className:"opacity-60",children:[t.stepCount," 步"]})]},t.key):ye(t.step)),N.totalHeight-N.offsets[B.end]>0&&e.jsx("div",{"aria-hidden":"true","data-virtual-spacer":"bottom",style:{height:N.totalHeight-N.offsets[B.end],flexShrink:0}})]}):Z.map(t=>e.jsxs("div",{className:"bl-tr-turn-group",children:[e.jsxs("div",{className:"bl-tr-turn-head mono",children:[e.jsx("span",{children:t.turnIndex>0?`#${t.turnIndex} 轮`:"会话前置"}),e.jsxs("span",{className:"opacity-60",children:[t.steps.length," 步"]})]}),e.jsx("div",{className:"bl-tr-turn-items",children:t.steps.map(ye)})]},`turn-${t.turnIndex}`))}),e.jsx("div",{className:"bl-tr-inspector","data-testid":"trace-inspector",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bl-tr-inspector-head",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"bl-tr-inspector-meta mono",children:[e.jsx("span",{className:"bl-tr-lane-dot","data-lane":s.lane}),e.jsx("span",{children:((Te=ue[s.kind])==null?void 0:Te.label)??s.kind}),s.turnIndex>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bl-tr-sep",children:"·"}),e.jsxs("span",{children:["#",s.turnIndex]})]}),s.toolName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bl-tr-sep",children:"·"}),e.jsx("span",{className:"truncate",children:s.toolName})]})]}),e.jsx("h3",{className:"bl-tr-inspector-title",title:s.title,children:s.title})]}),e.jsx("div",{className:"bl-tr-tab-switch",role:"tablist","aria-label":"步骤检查器视图",children:[{id:"overview",label:"概述"},{id:"preview",label:"预览"},{id:"raw",label:"原始内容"}].map(t=>e.jsx("button",{type:"button",role:"tab","aria-selected":_===t.id,"data-testid":`trace-tab-${t.id}`,"data-active":_===t.id?"true":"false",onClick:()=>_e(t.id),className:"bl-tr-switch-btn",children:t.label},t.id))})]}),e.jsxs("div",{className:"bl-tr-inspector-body",children:[_==="overview"&&e.jsxs("div",{className:"bl-tr-overview","data-testid":"trace-panel-overview",children:[e.jsxs("dl",{className:"bl-tr-kv-grid",children:[e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"来源"}),e.jsx("dd",{children:((we=Se[n.source])==null?void 0:we.label)??n.source})]}),e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"类型"}),e.jsx("dd",{children:((Me=ue[s.kind])==null?void 0:Me.label)??s.kind})]}),e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"状态"}),e.jsx("dd",{"data-status":s.status,children:rt[s.status]??s.status})]}),(s.model||n.model)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"模型"}),e.jsx("dd",{className:"mono",children:s.model||n.model})]}),s.toolName&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"工具"}),e.jsx("dd",{className:"mono",children:s.toolName})]}),f(s.exitCode)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"退出码"}),e.jsx("dd",{className:"mono","data-status":s.exitCode===0?"ok":"error",children:s.exitCode})]})]}),it(s.tokens)&&s.tokens&&e.jsxs("section",{className:"bl-tr-card","data-testid":"trace-token-section",children:[e.jsx("div",{className:"caps mb-1.5",children:"Token 用量"}),e.jsxs("dl",{className:"bl-tr-kv-grid",children:[y(s.tokens.inputTokens)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"输入"}),e.jsx("dd",{className:"mono",children:y(s.tokens.inputTokens)})]}),y(s.tokens.outputTokens)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"输出"}),e.jsx("dd",{className:"mono",children:y(s.tokens.outputTokens)})]}),y(s.tokens.cacheReadTokens)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"缓存读取"}),e.jsx("dd",{className:"mono",children:y(s.tokens.cacheReadTokens)})]}),y(s.tokens.cacheWriteTokens)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"缓存写入"}),e.jsx("dd",{className:"mono",children:y(s.tokens.cacheWriteTokens)})]}),y(s.tokens.reasoningTokens)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"推理"}),e.jsx("dd",{className:"mono",children:y(s.tokens.reasoningTokens)})]}),y(s.tokens.totalTokens)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"总计"}),e.jsx("dd",{className:"mono",children:y(s.tokens.totalTokens)})]})]})]}),s.thinkingText&&s.thinkingText.trim().length>0&&e.jsxs("section",{className:"bl-tr-card","data-testid":"trace-thinking-card",children:[e.jsxs("button",{type:"button",className:"bl-tr-thinking-toggle","data-testid":"trace-thinking-toggle","aria-expanded":Y,onClick:()=>se(t=>!t),children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium",children:[e.jsx(Ae,{size:13,"aria-hidden":"true"}),e.jsx("span",{children:"思考过程"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px]",style:{color:"var(--faint)"},children:[e.jsx("span",{children:Y?"收起":"展开"}),Y?e.jsx(Je,{size:13}):e.jsx(Ye,{size:13})]})]}),Y?e.jsx("div",{className:"bl-tr-thinking-body whitespace-pre-wrap break-words","data-testid":"trace-thinking-body",children:s.thinkingText}):e.jsx("div",{className:"bl-tr-thinking-teaser truncate",children:s.thinkingText.replace(/\s+/g," ").trim()})]}),s.toolArgs||s.toolOutput?e.jsxs("section",{className:"bl-tr-card space-y-2",children:[s.toolArgs&&e.jsxs("div",{children:[e.jsx("div",{className:"caps mb-1",children:"调用参数"}),e.jsx("pre",{className:"bl-tr-pre mono",children:s.toolArgs})]}),s.toolOutput&&e.jsxs("div",{children:[e.jsx("div",{className:"caps mb-1",children:"执行输出"}),e.jsx("pre",{className:"bl-tr-pre mono",children:s.toolOutput})]})]}):s.summary||s.previewText?e.jsxs("section",{className:"bl-tr-card",children:[e.jsx("div",{className:"caps mb-1",children:"内容摘要"}),e.jsx("p",{className:"text-[12.5px] leading-relaxed whitespace-pre-wrap break-words",children:s.summary||s.previewText})]}):null,lt(s)&&e.jsxs("section",{className:"bl-tr-card","data-testid":"trace-timing-section",children:[e.jsx("div",{className:"caps mb-1.5",children:"请求计时"}),e.jsxs("dl",{className:"bl-tr-kv-grid",children:[Ce(s.startedAt)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"开始时间"}),e.jsx("dd",{className:"mono",children:Ce(s.startedAt)})]}),E(s.durationMs)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"总耗时"}),e.jsx("dd",{className:"mono",children:E(s.durationMs)})]}),E(s.ttftMs)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"首字延迟 (TTFT)"}),e.jsx("dd",{className:"mono",children:E(s.ttftMs)})]}),E(s.generationMs)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"生成耗时"}),e.jsx("dd",{className:"mono",children:E(s.generationMs)})]}),Ie(s.tps)&&e.jsxs("div",{className:"bl-tr-kv",children:[e.jsx("dt",{children:"吞吐速度"}),e.jsx("dd",{className:"mono",children:Ie(s.tps)})]})]})]})]}),_==="preview"&&e.jsx("div",{className:"bl-tr-preview","data-testid":"trace-panel-preview",children:s.kind==="tool_call"||s.kind==="tool_result"?e.jsxs("div",{className:"space-y-3",children:[s.toolArgs&&e.jsxs("div",{className:"bl-tr-code-box",children:[e.jsxs("div",{className:"bl-tr-code-head",children:[e.jsx("span",{className:"caps",children:"参数"}),e.jsxs("button",{type:"button",onClick:()=>void ie("args",s.toolArgs),className:"bl-tr-copy-btn",children:[P==="args"?e.jsx(oe,{size:11}):e.jsx(de,{size:11}),e.jsx("span",{children:P==="args"?"已复制":"复制"})]})]}),e.jsx("pre",{className:"bl-tr-pre bl-tr-pre-tall mono",children:s.toolArgs})]}),s.toolOutput&&e.jsxs("div",{className:"bl-tr-code-box",children:[e.jsxs("div",{className:"bl-tr-code-head",children:[e.jsx("span",{className:"caps",children:"输出"}),e.jsxs("button",{type:"button",onClick:()=>void ie("output",s.toolOutput),className:"bl-tr-copy-btn",children:[P==="output"?e.jsx(oe,{size:11}):e.jsx(de,{size:11}),e.jsx("span",{children:P==="output"?"已复制":"复制"})]})]}),e.jsx("pre",{className:"bl-tr-pre bl-tr-pre-tall mono",children:s.toolOutput})]}),!s.toolArgs&&!s.toolOutput&&e.jsx("div",{className:"bl-tr-muted-empty",children:"该工具步骤未记录可预览的参数或输出。"})]}):s.previewText||s.thinkingText||s.summary?e.jsx("div",{className:"bl-tr-markdown-wrap",children:e.jsx(Fe,{content:s.previewText||s.thinkingText||s.summary||""})}):e.jsx("div",{className:"bl-tr-muted-empty",children:"该步骤暂无可渲染的预览正文。"})}),_==="raw"&&e.jsx("div",{className:"bl-tr-raw","data-testid":"trace-panel-raw",children:le?e.jsxs("div",{className:"bl-tr-code-box",children:[e.jsxs("div",{className:"bl-tr-code-head",children:[e.jsx("span",{className:"caps",children:"RAW PAYLOAD"}),e.jsxs("button",{type:"button","data-testid":"trace-raw-copy-btn",onClick:()=>void ie("raw",le),className:"bl-tr-copy-btn",children:[P==="raw"?e.jsx(oe,{size:11}):e.jsx(de,{size:11}),e.jsx("span",{children:P==="raw"?"已复制":"复制"})]})]}),e.jsx("pre",{className:"bl-tr-pre bl-tr-pre-tall mono",children:le})]}):e.jsx("div",{className:"bl-tr-muted-empty",children:"该步骤未附带原始 JSON / 底层事件负载。"})})]})]}):e.jsx("div",{className:"bl-tr-muted-empty",children:"在左侧或上方时间轴中选择任意步骤以查看详情。"})})]})]})};export{kt as ExecutionTraceView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,a as se,j as c}from"./vendor-react-CIotE-6Q.js";import{C as ie,b as le}from"./vendor-icons-BeN0on9X.js";const L=6,m=10;function K(o){return o.findIndex(n=>!n.disabled)}function ce(o){for(let n=o.length-1;n>=0;n-=1)if(!o[n].disabled)return n;return-1}function T(o,n,D){const h=o.length;if(h===0)return-1;let p=n;for(let k=0;k<h;k+=1)if(p=(p+D+h)%h,!o[p].disabled)return p;return-1}function fe({value:o,options:n,onChange:D,ariaLabel:h,placeholder:p,defaultValue:k,size:A="sm",fullWidth:q=!1,className:V="",menuClassName:J="",minMenuWidth:z=152,maxMenuWidth:X=360,disabled:C=!1,testId:H}){const[l,y]=i.useState(!1),[x,b]=i.useState(-1),[d,$]=i.useState(null),G=i.useId(),P=i.useRef(null),M=i.useRef(null),v=i.useMemo(()=>n.findIndex(e=>e.value===o),[n,o]),j=v>=0?n[v]:void 0,Q=!j&&!!p,O=(j==null?void 0:j.label)??p??"",Y=k!==void 0&&o!==k,g=i.useCallback(()=>{const e=P.current;if(!e)return null;const a=e.getBoundingClientRect(),s=window.innerWidth||1440,u=window.innerHeight||900,t=Math.max(160,Math.min(X,s-m*2)),r=Math.min(Math.max(Math.ceil(a.width),z),t),f=M.current,N=Math.min(288,n.length*34+14),W=f&&f.offsetWidth>0?Math.min(t,Math.max(r,Math.ceil(f.offsetWidth))):r,_=f&&f.offsetHeight>0?Math.ceil(f.offsetHeight):N;let w=a.left;w+W>s-m&&(w=a.right-W),w=Math.max(m,Math.min(w,s-W-m));const R=u-a.bottom-L-m,B=a.top-L-m,S=R<_&&B>R,F=Math.max(120,Math.min(320,S?B:R)),ne=Math.min(_,F),ae=S?Math.max(m,a.top-L-ne):Math.max(m,a.bottom+L),re=a.left+a.width/2,oe=Math.max(18,Math.min(W-18,Math.round(re-w)));return{left:Math.round(w),top:Math.round(ae),minWidth:r,maxWidth:Math.round(t),maxHeight:Math.round(F),originX:oe,placement:S?"top":"bottom"}},[X,z,n.length]),E=i.useCallback((e=!1)=>{var a;y(!1),e&&((a=P.current)==null||a.focus({preventScroll:!0}))},[]),U=i.useCallback(e=>{var u,t;if(C||n.length===0)return;const a=v>=0&&!((u=n[v])!=null&&u.disabled)?v:K(n),s=e!==void 0&&e>=0&&!((t=n[e])!=null&&t.disabled)?e:a;b(s),$(g()),y(!0)},[g,C,v,n]),I=i.useCallback(e=>{e.disabled||(e.value!==o&&D(e.value),E(!0))},[E,D,o]);i.useLayoutEffect(()=>{if(!l)return;const e=g();e&&$(e)},[l,n.length,g]),i.useEffect(()=>{var a,s;if(!l||x<0)return;const e=(a=M.current)==null?void 0:a.querySelector(`[data-option-index="${x}"]`);(s=e==null?void 0:e.scrollIntoView)==null||s.call(e,{block:"nearest"})},[l,x]),i.useEffect(()=>{if(!l)return;const e=t=>{var f,N;const r=t.target;r instanceof Node&&((f=P.current)!=null&&f.contains(r)||(N=M.current)!=null&&N.contains(r)||y(!1))},a=t=>{if(t.key==="Escape"){t.preventDefault(),t.stopPropagation(),E(!0);return}if(t.key==="ArrowDown"){t.preventDefault(),t.stopPropagation(),b(r=>T(n,r<0?-1:r,1));return}if(t.key==="ArrowUp"){t.preventDefault(),t.stopPropagation(),b(r=>T(n,r<0?0:r,-1));return}if(t.key==="Home"){t.preventDefault(),t.stopPropagation(),b(K(n));return}if(t.key==="End"){t.preventDefault(),t.stopPropagation(),b(ce(n));return}if(t.key==="Enter"||t.key===" "){t.preventDefault(),t.stopPropagation();const r=x>=0?n[x]:void 0;r&&!r.disabled&&I(r);return}t.key==="Tab"&&y(!1)},s=()=>{const t=g();t&&$(t)},u=t=>{var r;t.target instanceof Node&&((r=M.current)!=null&&r.contains(t.target))||y(!1)};return document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",a,!0),window.addEventListener("resize",s,{passive:!0}),window.addEventListener("scroll",u,{passive:!0,capture:!0}),()=>{document.removeEventListener("pointerdown",e,!0),document.removeEventListener("keydown",a,!0),window.removeEventListener("resize",s),window.removeEventListener("scroll",u,!0)}},[x,E,I,g,l,n]);const Z=e=>{l||(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="Enter"||e.key===" ")&&(e.preventDefault(),U())},ee=A==="xs"?11.5:13,te=l&&d&&typeof document<"u"?se.createPortal(c.jsx("div",{ref:M,id:G,role:"listbox","aria-label":h,"data-testid":H?`${H}-menu`:void 0,"data-placement":d.placement,className:`bl-lselect-menu ${J}`.trim(),style:{left:`${d.left}px`,top:`${d.top}px`,minWidth:`${d.minWidth}px`,maxWidth:`${d.maxWidth}px`,maxHeight:`${d.maxHeight}px`,transformOrigin:`${d.originX}px ${d.placement==="top"?"bottom":"top"}`},onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:c.jsx("div",{className:"bl-lselect-list",children:n.map((e,a)=>{const s=e.value===o,u=!e.disabled&&a===x;return c.jsxs("button",{type:"button",role:"option",disabled:e.disabled,"aria-selected":s,"aria-disabled":e.disabled?"true":void 0,"data-option-index":a,"data-option-value":e.value,"data-selected":s?"true":"false","data-active":u?"true":"false","data-disabled":e.disabled?"true":void 0,onMouseEnter:()=>{e.disabled||b(a)},onClick:()=>I(e),className:"bl-lselect-option",title:e.label,children:[c.jsx("span",{className:"bl-lselect-check","aria-hidden":"true",children:s?c.jsx(ie,{size:13,strokeWidth:2.5}):null}),c.jsx("span",{className:"bl-lselect-opt-label truncate",children:e.label}),e.hint&&c.jsx("span",{className:"bl-lselect-opt-hint mono",children:e.hint})]},e.value)})})}),document.body):null;return c.jsxs(c.Fragment,{children:[c.jsxs("button",{ref:P,type:"button",role:"combobox",disabled:C,"aria-label":h,"aria-haspopup":"listbox","aria-expanded":l,"aria-controls":l?G:void 0,"data-testid":H,"data-value":o,"data-size":A,"data-full-width":q?"true":void 0,"data-placeholder":Q?"true":void 0,"data-open":l?"true":"false","data-filtered":Y?"true":"false",onClick:()=>l?E(!1):U(),onKeyDown:Z,className:`bl-lselect-trigger ${V}`.trim(),title:O,children:[c.jsx("span",{className:"bl-lselect-value truncate",children:O}),c.jsx(le,{size:ee,strokeWidth:2.1,className:"bl-lselect-chevron shrink-0","aria-hidden":"true"})]}),te]})}export{fe as L};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,j as s}from"./vendor-react-CIotE-6Q.js";import{u as h,a as p}from"./index-CuRBE0Be.js";import"./vendor-icons-BeN0on9X.js";const v=[],A=()=>{const l=h(e=>e.logOpen),x=h(e=>e.setLogOpen),c=p(e=>e.instances),y=p(e=>e.stopBranch),g=p(e=>e.stopAll),d=r.useCallback(()=>x(!1),[x]),b=e=>void y(e),j=()=>void g(),n=r.useMemo(()=>Object.values(c).sort((e,t)=>t.lastUsedAt-e.lastUsedAt),[c]),[a,f]=r.useState(""),m=r.useRef(null);r.useEffect(()=>{(!a&&n.length>0||a&&!c[a]&&n.length>0)&&f(n[0].ref)},[n,a,c]);const o=a?c[a]??n[0]:n[0],i=(o==null?void 0:o.ref)??"",u=p(e=>{var t;return i?e.instanceLogsByRef[i]??((t=e.instances[i])==null?void 0:t.logs)??v:v});return r.useEffect(()=>{if(!l)return;const e=()=>{const t=m.current;t&&(t.scrollTop=t.scrollHeight)};if(typeof requestAnimationFrame=="function"){const t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)}e()},[l,i,u]),r.useEffect(()=>{if(!l)return;const e=t=>{t.key==="Escape"&&d()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l,d]),l?s.jsxs("div",{role:"dialog","aria-label":"运行日志",className:"bl-drawer h-52 shrink-0 flex flex-col",children:[s.jsxs("div",{className:"h-9 px-4 flex items-center justify-between gap-4 shrink-0",style:{borderBottom:"1px solid var(--hair)",background:"var(--surface)"},children:[s.jsxs("div",{className:"flex items-center gap-4 overflow-x-auto min-w-0",children:[s.jsx("span",{className:"caps shrink-0",children:"运行日志"}),n.length===0?s.jsx("span",{className:"text-[11px]",style:{color:"var(--faint)"},children:"暂无运行实例"}):n.map(e=>{const t=(o==null?void 0:o.ref)===e.ref;return s.jsxs("button",{type:"button",onClick:()=>f(e.ref),className:"text-xs shrink-0 pb-0.5 flex items-baseline gap-1.5",style:{color:t?"var(--ink)":"var(--muted)",fontWeight:t?600:400,borderBottom:t?"1.5px solid var(--ink)":"1.5px solid transparent"},children:[s.jsx("span",{children:e.label}),e.proxyPort&&e.status==="ready"&&s.jsxs("span",{className:"mono text-[10px]",style:{color:"var(--faint)"},children:[":",e.proxyPort]})]},e.ref)})]}),s.jsxs("div",{className:"flex items-center gap-3 text-xs shrink-0",children:[o&&o.status!=="stopped"&&o.status!=="idle"&&s.jsx("button",{type:"button",onClick:()=>b(o.ref),className:"hover:underline underline-offset-4",style:{color:"var(--accent)"},children:"停止当前"}),n.length>0&&s.jsx("button",{type:"button",onClick:j,className:"hover:underline underline-offset-4",style:{color:"var(--muted)"},children:"全部停止"}),s.jsx("button",{type:"button",onClick:d,className:"mono text-sm px-1 opacity-60 hover:opacity-100","aria-label":"关闭日志",children:"×"})]})]}),s.jsx("div",{ref:m,className:"flex-1 overflow-y-auto px-5 py-3 mono text-xs leading-5",style:{color:"var(--muted)"},children:o?u.length===0?s.jsx("div",{children:o.statusMessage}):u.map((e,t)=>s.jsx("div",{className:"whitespace-pre-wrap break-all",children:e},t)):s.jsx("div",{style:{color:"var(--faint)"},children:"启动任意分支预览服务后,此处实时输出构建与运行日志。"})})]}):null};export{A as LogDrawer};
|