@customize-agent/server 4.28.0 → 4.29.0
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/chunks/1049.js +52 -52
- package/.next/server/chunks/208.js +3 -3
- package/.next/server/chunks/5284.js +39 -39
- package/.next/server/chunks/8163.js +10 -10
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages/asset-library.html +1 -1
- package/.next/server/pages/document-roles.html +1 -1
- package/.next/server/pages/documents.html +1 -1
- package/.next/server/pages/guide.html +1 -1
- package/.next/server/pages/index.html +1 -1
- package/.next/server/pages/knowledge/file-detail.html +1 -1
- package/.next/server/pages/knowledge/files.html +1 -1
- package/.next/server/pages/knowledge/manage.html +1 -1
- package/.next/server/pages/knowledge.html +1 -1
- package/.next/server/pages/models.html +1 -1
- package/.next/server/pages/overview.html +1 -1
- package/.next/server/pages/prompt.html +1 -1
- package/.next/server/pages/settings.html +1 -1
- package/.next/server/pages/system/logs.html +1 -1
- package/.next/server/pages-manifest.json +24 -24
- package/.next/static/{ZQPm9kfCN8D4JwXka8x8f → EflxRTr7hU_QE2xJZeRh_}/_buildManifest.js +1 -1
- package/.next/static/chunks/pages/documents-03a1030c2ec3088e.js +1 -0
- package/package.json +1 -1
- package/.next/static/chunks/pages/documents-94461ba9ab16c014.js +0 -1
- /package/.next/static/{ZQPm9kfCN8D4JwXka8x8f → EflxRTr7hU_QE2xJZeRh_}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[298],{16403:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/documents",function(){return r(81865)}])},81865:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>ev});var s=r(65321),l=r(97109),a=r(26171),n=r(7576),o=r(35292),i=r(33442),c=r(17807),d=r(63455),u=r(11702),p=r(88762),m=r(85114),x=r(58569),h=r(84253),g=r(34052),v=r(68787),f=r(55122),j=r(42700),y=r(2256),w=r(38770),b=r(38332),A=r(76506),k=r(50883),S=r(23718),C=r(23216),N=r(26619),I=r(8263),T=r(16285),R=r(8579),M=r(7851),z=r(29071),E=r(75548),F=r(63552),_=r(26631),D=r(7225),B=r(83914),P=r(84742),q=r(58209),L=r(38762),W=r(8470),G=r(92783),O=r(54746),H=r(93051),U=r(82930),V=r(64068),K=r(64629),Q=r(1310),X=r(67547),J=r(76830),Y=r(6578),Z=r(48321);let $={"fact-landing-round":"未覆盖重要事实落地","table-repair-round":"表格缺失或格式错误","semantic-choice-conflict":"语义矛盾数值冲突","deterministic-stage5":"确定性缺陷(来源罗列/内部术语/编造日期)","formal-source-clean":"资料来源罗列话术","qingtian-full-review":"全维度评审缺陷","planned-section-final":"规划小节内容缺失","commercial-strip":"商务数据泄漏","table-deterministic-repair":"表格数据不一致","post-review-surface":"评审后兜底缺陷","terminology-strip":"内部术语泄漏","toc-consistency":"目录与正文不一致"},{TextArea:ee}=n.A,{Text:et}=o.A,er=a.A;function es(e){let{type:t="info",title:r,children:l,style:a}=e,n="error"===t?"var(--colorError)":"warning"===t?"var(--colorWarning)":"success"===t?"var(--colorSuccess)":"var(--colorInfo)";return(0,s.jsxs)("div",{style:{border:"1px solid ".concat(n),background:"error"===t?"var(--colorErrorBg)":"warning"===t?"var(--colorWarningBg)":"success"===t?"var(--colorSuccessBg)":"var(--colorInfoBg)",borderRadius:8,padding:"9px 12px",...a},children:[(0,s.jsx)(et,{strong:!0,style:{color:n},children:r}),l&&(0,s.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12},children:l})]})}function el(e){let{children:t,gap:r=12,style:l}=e;return(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:r,...l},children:t})}let ea=null,en=!1;function eo(){null==ea||ea.listeners.forEach(e=>e())}let ei={role_binding:(0,s.jsx)(C.A,{}),knowledge_retrieval:(0,s.jsx)(N.A,{}),file_understanding:(0,s.jsx)(I.A,{}),fact_extraction:(0,s.jsx)(T.A,{}),chapter_generation:(0,s.jsx)(R.A,{}),validation:(0,s.jsx)(M.A,{}),llm_review:(0,s.jsx)(z.A,{}),reference:(0,s.jsx)(E.A,{})},ec={施工组织设计:(0,s.jsx)(M.A,{}),投标文件:(0,s.jsx)(F.A,{}),技术方案:(0,s.jsx)(T.A,{}),报告:(0,s.jsx)(_.A,{}),自定义:(0,s.jsx)(R.A,{})};function ed(e){return[...new Set(e.map(e=>e.trim()).filter(Boolean))]}function eu(e){return e.map(e=>({key:e.key,value:e.key,rawTitle:e.title,title:e.isFolder?(0,s.jsxs)("div",{className:"flex items-center justify-between w-full pr-4",children:[(0,s.jsxs)(i.A,{size:4,children:[(0,s.jsx)(D.A,{style:{color:"#faad14"}}),(0,s.jsx)("span",{children:e.title})]}),(0,s.jsxs)("span",{className:"text-xs text-[var(--colorTextTertiary)]",children:[e.fileCount||0," 项"]})]}):(0,s.jsx)("span",{title:e.key,children:e.title}),isFolder:e.isFolder,fileCount:e.fileCount||+!e.isFolder,isLeaf:e.isLeaf}))}let ep={role_binding:"角色配置绑定",knowledge_retrieval:"知识库检索",file_understanding:"多模态文件理解",fact_extraction:"LLM 事实抽取",chapter_generation:"LLM 章节生成",validation:"规则校验",llm_review:"LLM 审查优化",reference:"参考资源处理"},em={"knowledge-base":"知识库","document-readiness":"生成准备度检查"},ex={wait:"common.statusWaiting",process:"common.statusRunning",finish:"common.statusCompleted",warning:"common.statusReview",error:"common.statusAbnormal"},eh={running:"common.statusRunning",success:"common.statusCompleted",skipped:"common.statusSkipped",failed:"common.statusFailed"},eg={error:"common.levelError",warning:"common.levelWarning",info:"common.levelInfo"};function ev(){var e,t,r,a,o,E,F,D;let ev=(0,Z.Vr)(),{message:ef}=c.A.useApp(),[ej]=d.A.useForm(),ey=(0,l.useRef)(null),[ew,eb]=(0,l.useState)([]),[eA,ek]=(0,l.useState)("construction-organization-design"),[eS,eC]=(0,l.useState)([]),[eN,eI]=(0,l.useState)([]),[eT,eR]=(0,l.useState)([]),[eM,ez]=(0,l.useState)([]),[eE,eF]=(0,l.useState)(!1),[e_,eD]=(0,l.useState)(!0),[eB,eP]=(0,l.useState)(!1),[eq,eL]=(0,l.useState)(null),[eW,eG]=(0,l.useState)(""),[eO,eH]=(0,l.useState)([]),[eU,eV]=(0,l.useState)(null),[eK,eQ]=(0,l.useState)(null),[eX,eJ]=(0,l.useState)(""),[eY,eZ]=(0,l.useState)(!1),[e$,e0]=(0,l.useState)("idle"),[e1,e2]=(0,l.useState)(null),[e6,e5]=(0,l.useState)(null),[e8,e3]=(0,l.useState)({start:0,end:0}),[e4,e7]=(0,l.useState)([]),[e9,te]=(0,l.useState)(!1),[tt,tr]=(0,l.useState)(!1),[ts,tl]=(0,l.useState)({}),[ta,tn]=(0,l.useState)(null),to=(0,l.useRef)({}),ti=(0,l.useRef)(new Map),[tc,td]=(0,l.useState)(0),[tu,tp]=(0,l.useState)([]),tm=(0,l.useMemo)(()=>{var e,t,r;return(null==(e=eT.find(e=>e.selected))?void 0:e.projectRoot)||(null==(t=eT.find(e=>e.isCurrent))?void 0:t.projectRoot)||(null==(r=eT[0])?void 0:r.projectRoot)||""},[eT]),[tx,th]=(0,l.useState)([]),[tg,tv]=(0,l.useState)(null),[tf,tj]=(0,l.useState)(null),[ty,tw]=(0,l.useState)("templates"),[tb,tA]=(0,l.useState)(!1),[tk,tS]=(0,l.useState)("workflow"),[tC,tN]=(0,l.useState)(new Set),[tI,tT]=(0,l.useState)(!1),[tR,tM]=(0,l.useState)(!1),[tz,tE]=(0,l.useState)(null),tF=(0,l.useRef)(new Map),t_=(0,l.useRef)(!1),tD=(0,l.useRef)(""),tB=(0,l.useRef)(null),tP=(0,l.useRef)(0),tq=(0,l.useMemo)(()=>"activeGenDocId:".concat(tm||"default"),[tm]),tL=async()=>{try{eH((await (0,Y.cQ)(tm||void 0)).documents)}catch(e){eH([])}};(0,l.useEffect)(()=>{let e=()=>{ea&&(th(ea.flowSteps),tv(ea.activeFlowKey),eP(ea.loading),ea.documentId&&eV(ea.documentId),ea.draft&&eL(ea.draft),void 0!==ea.content&&eG(ea.content))},t=ea;return null==t||t.listeners.add(e),e(),()=>{null==t||t.listeners.delete(e)}},[]),(0,l.useEffect)(()=>{eD(!0),Promise.all([(0,Y.Dl)().then(e=>{var t,r;eb(e.templates),ek(null!=(r=null==(t=e.templates[0])?void 0:t.id)?r:"construction-organization-design")}),(0,Y.lv)().then(e=>{eC(e.roles),eI(e.configs)}),(0,Y.dx)().then(e=>eR(e))]).catch(()=>ef.error(ev("common.error"))).finally(()=>eD(!1))},[ef,ev]),(0,l.useEffect)(()=>{if(0===ew.length||!tm)return;let e=!1;return(async()=>{let t=await Promise.all(ew.map(async e=>{try{let{validation:t}=await (0,Y.SM)(e.id,tm);return[e.id,t]}catch(e){return null}}));if(e)return;let r={};for(let e of t)e&&(r[e[0]]=e[1]);tl(r)})(),()=>{e=!0}},[ew,tm]),(0,l.useEffect)(()=>{tm&&(localStorage.removeItem("activeGenDocId"),tL())},[tm]),(0,l.useEffect)(()=>{if(0===eO.length)return;let e=localStorage.getItem(tq);if(!e)return;if(!eO.find(t=>t.id===e&&("generating"===t.status||"queued"===t.status)))return void localStorage.removeItem(tq);let t=setInterval(()=>{(async()=>{try{let{document:r}=await (0,Y.v7)(e,!1,tm||void 0);if(!r)return;await tL(),"generating"!==r.status&&"queued"!==r.status&&(localStorage.removeItem(tq),clearInterval(t))}catch(e){clearInterval(t)}})()},3e3);return()=>clearInterval(t)},[eO]);let tW=(0,l.useMemo)(()=>ew.find(e=>e.id===eA),[ew,eA]),tG=eN.map(e=>({label:e.name,value:e.id})),tO=Math.max(0,tx.findIndex(e=>e.key===tg)),tH=e=>{var t;return e?(null==(t=eS.find(t=>t.id===e))?void 0:t.name)||em[e]||"未知角色":""},tU=e=>e.subtitle||e.roleName||tH(e.roleId)||ep[e.type]||e.type,tV=e=>{var t,r,s;return e.promptName||((t=e.promptId)?(null==(r=eT.find(e=>e.id===t))?void 0:r.projectName)||(null==(s=eS.find(e=>e.id===t))?void 0:s.name)||em[t]||"未知提示词":"")},tK=()=>{tP.current+=1,eJ(""),e2(null),e5(null),e7([]),te(!1),eZ(!1),e0("idle")},tQ=async e=>{eV(e.id),ek(e.templateId);let t=tX(e.status);if(t||"failed"===e.status||"aborted"===e.status){tK(),tj(e),eL(null),eG(""),eP(t),tS("workflow"),tA(!0);try{let{document:t}=await (0,Y.v7)(e.id,!1,e.projectRoot||tm||void 0);if(!t)throw Error("文档记录不存在");t$(t),tX(t.status)?t6(t.id,t.projectRoot||e.projectRoot||tm||void 0):await tL()}catch(t){t$(e)}return}tS("editor"),th([]),tv(null),tK();try{let{document:t}=await (0,Y.v7)(e.id,!1,e.projectRoot||tm||void 0);if(!t)throw Error("文档记录不存在");eL(t.draft||null),eG(t.editedMarkdown||t.markdown),tp(t.exportReports||[])}catch(e){ef.error(ev("common.error"))}tA(!0)},tX=e=>"completed"!==e&&"completed_with_issues"!==e&&"warning"!==e&&"failed"!==e&&"aborted"!==e,tJ=e=>{var t,r,s,l,a,n;return!!e&&("failed"===e.status||"aborted"===e.status||"completed_with_issues"===e.status||"warning"===e.status&&!!(null==(t=e.checkpointChapters)?void 0:t.length)&&/继续生成|重新生成|中断|卡住|未完成|门禁|阻断/u.test(e.error||(null==(r=e.warningIssues)?void 0:r.join(";"))||(null==(a=e.draft)||null==(l=a.exportGate)||null==(s=l.blockingIssues)?void 0:s.map(e=>e.message).join(";"))||"")||!!((null==(n=e.draft)?void 0:n.exportGate)&&!1===e.draft.exportGate.passed))},tY=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:eB;(null==ea?void 0:ea.loading)&&(ea.flowSteps=e,ea.activeFlowKey=t,ea.loading=r,eo())},tZ=e=>{var t,r,l,a;let n=e.executionStages||(null==(t=e.draft)?void 0:t.executionStages)||[];if(n.length>0){let t=n.map((t,r)=>{var l;let a,n=("failed"===e.status||"aborted"===e.status)&&"running"===t.status||"failed"===(a=t.status)?"error":"running"===a?"process":"finish";return{key:"".concat(t.type,"-").concat(r),title:t.title||ep[t.type]||t.type,subtitle:tU(t),description:t.message||"",status:n,icon:"role_binding"===(l=t.type)?(0,s.jsx)(C.A,{}):"knowledge_retrieval"===l?(0,s.jsx)(N.A,{}):"file_understanding"===l?(0,s.jsx)(I.A,{}):"fact_extraction"===l?(0,s.jsx)(T.A,{}):"chapter_generation"===l?(0,s.jsx)(R.A,{}):"llm_review"===l?(0,s.jsx)(z.A,{}):"validation"===l?(0,s.jsx)(M.A,{}):(0,s.jsx)(_.A,{}),subSteps:((e,t,r)=>{let s=Array.isArray(e.details)?e.details.filter(Boolean):[],l=e.progress?"".concat(e.progress.label||"进度",":").concat(e.progress.current,"/").concat(e.progress.total):"",a=[...l?[l]:[],...s];return 0===a.length?[{key:"stage-".concat(r),title:tV(e)?"提示词:".concat(tV(e)):tU(e),status:t}]:a.map((e,s)=>({key:"stage-".concat(r,"-").concat(s),title:e,status:"process"===t&&0===s?"process":"error"===t&&0===s?"error":"warning"===t?"warning":"process"===t?"finish":t}))})(t,n,r)}});("generating"===e.status||"queued"===e.status)&&t.length>0&&t.every(e=>"process"!==e.status)&&t.push({key:"finishing-".concat(t.length),title:"生成收尾中",subtitle:"",description:"章节已全部生成,正在执行全局一致性审查与质量校验。",status:"process",icon:(0,s.jsx)(B.A,{}),subSteps:[]});let o="generating"===e.status||"queued"===e.status?(null==(r=t.at(-1))?void 0:r.key)||"prepare":"failed"===e.status||"aborted"===e.status?(null==(l=t.find(e=>"error"===e.status))?void 0:l.key)||(null==(a=t.at(-1))?void 0:a.key)||"prepare":"done";return{steps:t,activeKey:o}}return{steps:[],activeKey:null}},t$=e=>{let t=e.executionStages||[],r="".concat(e.id,"|").concat(e.updatedAt,"|").concat(e.status,"|").concat(e.error||"","|").concat(t.length,"|").concat(t.map(e=>{var t,r,s,l;return"".concat(e.status,":").concat(null!=(s=null==(t=e.progress)?void 0:t.current)?s:0,"/").concat(null!=(l=null==(r=e.progress)?void 0:r.total)?l:0)}).join(","));if(tD.current===r)return;tD.current=r,tj(e);let{steps:s,activeKey:l}=tZ(e);t0(s),th(s),tv(l),eP(tX(e.status)),tY(s,l,tX(e.status)),("failed"===e.status||"aborted"===e.status)&&tS("workflow"),("completed"===e.status||"completed_with_issues"===e.status||"warning"===e.status)&&e.draft&&(eL(e.draft),eG(e.editedMarkdown||e.markdown),tS("editor"),th([]),tv(null),tp(e.exportReports||[]))},t0=e=>{let t=Date.now();for(let r of e){let e=ti.current.get(r.key);"process"!==r.status||e?("finish"===r.status||"error"===r.status||"warning"===r.status)&&e&&!e.endedAt&&ti.current.set(r.key,{...e,endedAt:t}):ti.current.set(r.key,{startedAt:t})}},t1=e=>{let t=Math.max(0,Math.round(e/1e3));if(t<60)return"".concat(t," 秒");let r=Math.floor(t/60);return r<60?"".concat(r," 分 ").concat(t%60," 秒"):"".concat(Math.floor(r/60)," 小时 ").concat(r%60," 分")},t2=e=>{let t=tF.current.get(e);t&&(clearInterval(t),tF.current.delete(e))},t6=(e,t)=>{t2(e);let r=setInterval(()=>{(async()=>{try{let{document:r}=await (0,Y.v7)(e,!0,t||tm||void 0);if(!r)return;t$(r),await tL(),tX(r.status)||(t2(e),localStorage.removeItem(tq))}catch(e){}})()},2e3);tF.current.set(e,r)};(0,l.useEffect)(()=>()=>{for(let e of tF.current.values())clearInterval(e);tF.current.clear(),tB.current&&(clearTimeout(tB.current),tB.current=null)},[]),(0,l.useEffect)(()=>{if(!eB||!tg)return;let e=window.setInterval(()=>th(e=>{let t=e.map(e=>{if(e.key!==tg||"process"!==e.status)return e;let t=e.subSteps.findIndex(e=>"process"===e.status),r=t<0?0:Math.min(t+1,e.subSteps.length-1);return{...e,subSteps:e.subSteps.map((e,t)=>t<r?{...e,status:"finish"}:t===r?{...e,status:"process"}:{...e,status:"wait"})}});return tY(t,tg),t}),1400);return()=>window.clearInterval(e)},[tg,eB]),(0,l.useEffect)(()=>{if(!eB)return;let e=window.setInterval(()=>td(e=>e+1),1e3);return()=>window.clearInterval(e)},[eB]);let t5=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";eF(!0);try{let t=await (0,Y.Fi)(e,tm||void 0);ez(eu(t.nodes))}catch(e){ef.error("知识库文件加载失败")}finally{eF(!1)}},t8=async e=>{var t;let r=String(null!=(t=e.key)?t:"");if(r)try{let e=await (0,Y.Fi)(r,tm||void 0),t=eu(e.nodes),s=e=>e.map(e=>e.key===r?{...e,children:t}:e.children?{...e,children:s(e.children)}:e);ez(e=>s(e))}catch(e){ef.error("加载子文件夹失败")}},t3=e=>{let t=null!=e?e:{id:"tpl-".concat(Date.now()),name:"",description:"",category:"自定义",outputTitle:"",projectRoleConfigId:void 0,chapters:[],projectBindings:[]};ej.resetFields(),ej.setFieldsValue({...t,projectMaterialRoots:ed((t.projectBindings||[]).map(e=>e.materialRootPath).filter(Boolean))}),t5(),tr(!0)},t4=async()=>{try{await ej.validateFields();let e=ej.getFieldsValue(!0),t=ed(e.projectMaterialRoots||[]).map(e=>({materialRootPath:e})),{projectMaterialRoots:r,...s}=e,l={...s,chapters:[],projectBindings:t},a=await (0,Y.l2)(l);eb(a.templates),ek(a.template.id),tr(!1),await tL(),ef.success(ev("common.success"))}catch(e){e instanceof Error&&ef.error(e.message)}},t7=async e=>{try{let t=await (0,Y.bV)(e);eb(t.templates),ek(t.template.id),ef.success(ev("common.success"))}catch(e){ef.error(ev("common.error"))}},t9=async e=>{try{var t,r;let s=await (0,Y.h0)(e);eb(s.templates),ek(null!=(r=null==(t=s.templates[0])?void 0:t.id)?r:""),ef.success(ev("common.success"))}catch(e){ef.error(ev("common.error"))}},re=async e=>{tE(e),ek(e),eV(null),eL(null),eG(""),tK(),tS("workflow"),tA(!0),tw("drafts"),eP(!0),tv("prepare"),th([{key:"prepare",title:"正在准备运行模板",description:"正在校验模板绑定的项目资料包、提示词配置和资料索引,校验通过后会自动开始生成。",status:"process",icon:(0,s.jsx)(B.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"process"},{key:"start",title:"准备生成任务",status:"wait"}]}]);try{let{validation:t}=await (0,Y.SM)(e,tm||void 0);tl(r=>({...r,[e]:t}));let r=t.issues.filter(e=>"error"===e.level);if(r.length>0){rl.current=!0,eP(!1),tv("prepare"),th([{key:"prepare",title:"模板运行前检查未通过",description:r.map(e=>e.message).join("\n"),status:"error",icon:(0,s.jsx)(L.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"error"},{key:"start",title:"准备生成任务",status:"wait"}]}]),ef.warning("模板运行前检查未通过,请先处理阻断项");return}t.issues.length>0&&ef.warning("模板存在非阻断警告,已继续运行"),th([{key:"prepare",title:"模板检查通过,正在创建生成任务",description:"已确认模板绑定资源可用,正在启动后台生成任务。",status:"process",icon:(0,s.jsx)(B.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"finish"},{key:"start",title:"准备生成任务",status:"process"}]}]),await rs(e)}catch(t){rl.current=!0;let e=t instanceof Error?t.message:"模板运行前检查失败";eP(!1),th([{key:"prepare",title:"模板运行准备失败",description:e,status:"error",icon:(0,s.jsx)(L.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"error"},{key:"start",title:"准备生成任务",status:"wait"}]}]),ef.error(e)}finally{tE(t=>t===e?null:t)}},rt=async e=>{try{await (0,Y.QG)(e.id,e.projectRoot||tm||void 0),eU===e.id&&(eV(null),eL(null),eG("")),await tL(),ef.success(ev("common.success"))}catch(e){ef.error(ev("common.error"))}},rr=async(e,t)=>{let r=Date.now(),s=0,l=Date.now(),a=null,n=0;for(;;){let o,i;if(null==t?void 0:t.aborted)throw Error("用户中止");let c=new AbortController;t&&(t.pollController=c);try{let t=await (0,Y.v7)(e,!0,tm||void 0,c.signal,s||void 0);o=t.document,i=t.status,n=0}catch(e){if((null==t?void 0:t.aborted)||e instanceof DOMException&&"AbortError"===e.name)throw Error("用户中止",{cause:e});if((n+=1)>=3)throw e instanceof Error?e:Error("生成进度获取失败");await new Promise(e=>window.setTimeout(e,2e3*n));continue}finally{(null==t?void 0:t.pollController)===c&&(t.pollController=void 0)}let d=o?"queued"===o.status:"queued"===i;if(d&&(l=Date.now(),Date.now()-r>216e5))throw Error("排队等待超时,请稍后刷新列表查看或取消后重新发起");if(!o){if(!d&&(Date.now()-(null!=a?a:r)>75e5||Date.now()-l>96e4))throw Error("生成任务疑似卡住,请点击继续生成或重新生成(后台任务可能仍在运行,稍后刷新可查看)");await new Promise(e=>window.setTimeout(e,1500));continue}if(t$(o),"generating"===o.status&&null===a&&(a=Date.now()),o.updatedAt!==s&&(s=o.updatedAt,l=Date.now()),("completed"===o.status||"completed_with_issues"===o.status||"warning"===o.status)&&o.draft)return o;if("warning"===o.status&&o.error&&/已中断/u.test(o.error))throw Error(o.error);if("failed"===o.status||"aborted"===o.status)throw Error(o.error||("aborted"===o.status?"生成已中止":"生成失败"));if(!d&&(Date.now()-(null!=a?a:r)>75e5||Date.now()-l>96e4))throw Error("生成任务疑似卡住,请点击继续生成或重新生成(后台任务可能仍在运行,稍后刷新可查看)");await new Promise(e=>window.setTimeout(e,1500))}},rs=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eA;if(!e)return;if((null==ea?void 0:ea.aborted)&&(ea=null),null==ea?void 0:ea.loading){if(t_.current)return;if(!tm)return void ef.error("未识别当前项目,请先选择或打开项目后再生成文件");t_.current=!0;try{let t=await (0,Y.OX)({templateId:e,projectRoot:tm});await tL(),ef.info(t.queuePosition?"已加入生成队列(第 ".concat(t.queuePosition," 位):前面任务完成后将自动开始"):"生成任务已创建")}catch(e){ef.error(e instanceof Error?e.message:"创建生成任务失败")}finally{t_.current=!1}return}if(!tm)return void ef.error("未识别当前项目,请先选择或打开项目后再生成文件");eP(!0);let t=tx.length>0?tx:[{key:"prepare",title:"正在创建生成任务",description:"系统正在创建后台生成任务,请稍候。",status:"process",icon:(0,s.jsx)(B.A,{}),subSteps:[{key:"start",title:"准备生成任务",status:"process"}]}],r=tg||"prepare";th(t),tv(r);let l=(0,Y.OX)({templateId:e,projectRoot:tm});ea={id:Date.now(),templateId:e,loading:!0,flowSteps:t,activeFlowKey:r,promise:l,listeners:new Set};let a=[];try{let e=await l;e.documentId&&(localStorage.setItem(tq,e.documentId),eV(e.documentId),(null==ea?void 0:ea.promise)===l&&(ea.documentId=e.documentId)),await tL(),e.queuePosition&&ef.info("已加入生成队列(第 ".concat(e.queuePosition," 位):前面任务完成后将自动开始"));let t=e.documentId?await rr(e.documentId,(null==ea?void 0:ea.promise)===l?ea:void 0):void 0,r=e.draft||(null==t?void 0:t.draft);if(!r)throw Error("生成结果为空");(e.documentId||(null==t?void 0:t.id))&&eV(e.documentId||t.id),a.forEach(e=>window.clearTimeout(e)),eL(r),eG((null==t?void 0:t.editedMarkdown)||(null==t?void 0:t.markdown)||r.markdown),(null==ea?void 0:ea.promise)===l&&(ea.draft=r,ea.content=(null==t?void 0:t.editedMarkdown)||(null==t?void 0:t.markdown)||r.markdown);let s=t||{id:e.documentId||"draft-".concat(Date.now()),templateId:eA,title:r.title,requirement:r.requirement,projectRoot:r.projectRoot||tm,projectId:r.projectId,markdown:r.markdown,status:r.validationIssues.some(e=>"error"===e.level||"warning"===e.level)||!r.exportGate.passed?"warning":"completed",draft:r,executionStages:r.executionStages,assets:r.assets||[],createdAt:r.generatedAt,updatedAt:Date.now()},{steps:n}=tZ(s);th(n),tY(n,"done",!1),tv("done"),(null==ea?void 0:ea.promise)===l&&(ea.activeFlowKey="done",ea.loading=!1,eo(),ea=null),localStorage.removeItem(tq),await tL(),ef.success(ev("common.success")),window.setTimeout(()=>{var e;return null==(e=ey.current)?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},200)}catch(s){localStorage.removeItem(tq);let e=s instanceof Error?s.message:ev("common.error"),t=en;en=!1;let r=!t&&"用户中止"===e;t||th(t=>{let r=t.map(t=>"process"===t.status?{...t,status:"error",description:e,subSteps:((e,t)=>{if("wait"===t)return e.subSteps.map(e=>({...e,status:"wait"}));if("finish"===t)return e.subSteps.map(e=>({...e,status:"finish"}));if("error"===t)return e.subSteps.map((e,t)=>({...e,status:0===t?"error":e.status}));let r=e.subSteps.findIndex(e=>"wait"===e.status);return e.subSteps.map((e,t)=>t<r||-1===r?{...e,status:"finish"}:t===r?{...e,status:"process"}:e)})(t,"error")}:t);return tY(r,tg,!1),r}),(null==ea?void 0:ea.promise)===l&&(ea.loading=!1,ea.error=e,eo(),ea=null),await tL().catch(()=>void 0),r?ef.warning("生成任务已被中止(可能来自其他窗口):可在列表中点击「继续生成」恢复"):t||ef.error(e)}finally{a.forEach(e=>window.clearTimeout(e)),eP(!1),en=!1,(null==ea?void 0:ea.promise)===l&&(ea.loading=!1,eo())}},rl=(0,l.useRef)(!1);(0,l.useEffect)(()=>(tB.current&&(clearTimeout(tB.current),tB.current=null),!tb||"workflow"!==tk||tz||eU||rl.current||(null==ea?void 0:ea.loading)||null==tW||!tW.projectRoleConfigId||(rl.current=!0,tB.current=setTimeout(()=>{tB.current=null,tb&&"workflow"===tk&&!eU&&eA==eA&&rs()},300)),tb||(rl.current=!1),()=>{tB.current&&(clearTimeout(tB.current),tB.current=null)}),[tb,tk,tz,eU,tW,eA]);let ra=async e=>{try{eV(e.id),ek(e.templateId),tS("workflow"),tA(!0),eP(!0);let t=await (0,Y.UQ)(e.id,e.projectRoot||tm||void 0);localStorage.setItem(tq,t.documentId),await tL();let r=await rr(t.documentId);r.draft&&(eL(r.draft),eG(r.editedMarkdown||r.markdown||r.draft.markdown),tS("editor")),localStorage.removeItem(tq),await tL(),ef.success("已继续生成并完成")}catch(e){ef.error(e instanceof Error?e.message:"继续生成失败")}finally{eP(!1)}},rn=async e=>{if((null==ea?void 0:ea.loading)&&ea.documentId===e.id){var t;en=!0,ea.aborted=!0,null==(t=ea.pollController)||t.abort(),ea.loading=!1,ea.error="用户中止",eo(),ea=null,eP(!1)}localStorage.removeItem(tq),t2(e.id);try{await (0,Y.r)(e.id,e.projectRoot||tm||void 0),ef.success("queued"===e.status?"已取消排队任务":"已中止生成任务")}catch(e){ef.info("任务已不在运行,已刷新状态")}finally{await tL(),eU===e.id&&(eV(null),tj(null),eL(null),eG(""))}},ro=(e,t,r)=>{let s=new Blob([e],{type:r}),l=URL.createObjectURL(s),a=document.createElement("a");a.href=l,a.download=t,a.target="_self",a.rel="noopener",a.style.display="none",document.body.appendChild(a),a.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window})),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(l),1e3)},ri=async e=>{if(eq){eQ(e);try{let t={documentId:eU||void 0,title:eq.title,markdown:eW,format:e,enforceGate:!1,exportGate:eq.exportGate,useClientMarkdown:!0,projectRoot:eq.projectRoot||tm||void 0},r=await (0,Y.UE)(t);if(ro(r,"".concat(eq.title,".").concat("markdown"===e?"md":e),{markdown:"text/markdown;charset=utf-8",html:"text/html;charset=utf-8",pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}[e]),eU)try{let{document:e}=await (0,Y.v7)(eU,!1,eq.projectRoot||tm||void 0);e&&tp(e.exportReports||[])}catch(e){}}catch(e){ef.error(e instanceof Error?e.message:ev("common.error"))}finally{eQ(null)}}},rc=()=>{var e;return!!((null==tf?void 0:tf.editedMarkdown)||(null==tf?void 0:tf.markdown)||(null==tf||null==(e=tf.draft)?void 0:e.markdown)||"").trim()},rd=async e=>{var t;if(!tf)return;let r=tf.editedMarkdown||tf.markdown||(null==(t=tf.draft)?void 0:t.markdown)||"";if(!r.trim())return void ef.warning("该记录暂无可导出的正文内容");eQ(e);try{let t="markdown"===e?"md":e,s=await (0,Y.UE)({documentId:tf.id,title:tf.title,markdown:r,format:e,enforceGate:!1,useClientMarkdown:!0,projectRoot:tf.projectRoot||tm||void 0});ro(s,"".concat(tf.title,".").concat(t),{markdown:"text/markdown;charset=utf-8",html:"text/html;charset=utf-8",pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}[e])}catch(e){ef.error(e instanceof Error?e.message:ev("common.error"))}finally{eQ(null)}},ru=async()=>{if(eq)try{if(eU)await (0,Y.a6)(eU,{editedMarkdown:eW,markdown:eW},eq.projectRoot||tm||void 0);else{let e=await (0,Y.Af)({...eq,markdown:eW});eL(e.draft)}await tL(),ef.success(ev("common.success"))}catch(e){ef.error(ev("common.error"))}},rp=(e,t)=>{e7(r=>[{id:"".concat(Date.now()),content:e,prompt:t,createdAt:Date.now()},...r].slice(0,12))},rm=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e&&eJ(""),e2(null),e5(null),e3({start:0,end:0})},rx=(e,t)=>{var r,s;return{title:(null==eq?void 0:eq.title)||"未命名文档",markdown:t,instruction:e,facts:null==eq||null==(r=eq.structuredFacts)?void 0:r.map(e=>"".concat(e.key,": ").concat(e.value)),chapters:null==eq||null==(s=eq.chapters)?void 0:s.map(e=>e.title),...(()=>{let e=e8.start,t=e8.end;return t>e?{selection:{start:e,end:t,text:eW.slice(e,t)},cursorOffset:e}:{cursorOffset:e}})()}},rh=async()=>{let e=eX.trim();if(!eq||!e||eY)return;let t=tP.current+1;tP.current=t,eZ(!0),e0("planning"),e5(null);try{let r=await (0,Y.Gi)({mode:"plan",...rx(e,eW)});if(tP.current!==t||eU!=eU)return;if(!r.plan)throw Error("AI 未返回修改计划");e2(r.plan)}catch(e){tP.current===t&&ef.error(e instanceof Error?e.message:ev("common.error"))}finally{tP.current===t&&(eZ(!1),e0("idle"))}},rg=async e=>{let t=eX.trim();if(!eq||!t||eY)return;let r=tP.current+1;tP.current=r,eZ(!0),e0("applying");try{let s=await (0,Y.Gi)({mode:"apply",...rx(t,eW),plan:e});if(tP.current!==r||eU!=eU)return;if(!s.markdown)throw Error("AI 未返回修改结果");e5({plan:s.plan||e,markdown:s.markdown,beforeSnippet:s.beforeSnippet,afterSnippet:s.afterSnippet,summary:s.summary,changedChars:s.changedChars,prompt:t,before:eW})}catch(e){tP.current===r&&ef.error(e instanceof Error?e.message:ev("common.error"))}finally{tP.current===r&&(eZ(!1),e0("idle"))}};if(e_)return(0,s.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,s.jsx)(p.A,{active:!0,title:!0,paragraph:{rows:1}}),(0,s.jsx)(p.A,{active:!0,paragraph:{rows:2}}),(0,s.jsx)(p.A,{active:!0,paragraph:{rows:8}})]});let rv="workflow"===tk?"工作流:".concat((null==tW?void 0:tW.name)||"选择模板"):"编辑:".concat((null==eq?void 0:eq.title)||(null==tW?void 0:tW.outputTitle)||"文档");return(0,s.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end justify-between gap-4 pb-6 mb-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h1",{className:"text-3xl font-extrabold tracking-tight text-[var(--colorText)] mb-2.5 flex items-center gap-2",children:[(0,s.jsx)(C.A,{className:"text-[var(--colorAccent)]"}),ev("documents.title")]}),(0,s.jsx)("p",{className:"text-sm text-[var(--colorTextSecondary)]",children:ev("documents.description")})]}),(0,s.jsx)(m.Ay,{type:"primary",icon:(0,s.jsx)(O.A,{}),onClick:()=>t3(),className:"shadow-none rounded-lg",children:ev("documents.newTemplate")})]}),(0,s.jsxs)("div",{className:"bg-[var(--colorBgContainer)] rounded-2xl shadow-sm overflow-hidden",children:[(0,s.jsx)(x.A,{items:[{key:"templates",label:(0,s.jsxs)("span",{className:"px-4",children:["模板库 ",(0,s.jsx)(u.A,{className:"ml-2 border-0 bg-[var(--colorFillAlter)]",children:ew.length})]})},{key:"drafts",label:(0,s.jsxs)("span",{className:"px-4",children:["生成记录 ",(0,s.jsx)(u.A,{className:"ml-2 border-0 bg-[var(--colorFillAlter)]",children:eO.length})]})}],activeKey:ty,onChange:tw,className:"documents-tabs",size:"large",tabBarStyle:{margin:0,padding:"0 16px",background:"var(--colorBgHover)",borderBottom:"1px solid var(--borderColor)"}}),(0,s.jsx)("div",{className:"p-4 bg-[var(--colorFillAlter)] min-h-[500px]",children:"templates"===ty?0===ew.length?(0,s.jsx)("div",{className:"py-32 text-center border border-dashed border-[var(--borderColor)] rounded-2xl bg-[var(--colorBgContainer)]",children:(0,s.jsx)(h.A,{description:(0,s.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:ev("common.noData")})})}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4",children:ew.map(e=>(0,s.jsxs)("div",{ref:t=>{to.current[e.id]=t},className:"group flex items-center p-4 rounded-2xl transition-all cursor-pointer ".concat(eA===e.id?"bg-[var(--colorBgSelected)] shadow-md":"bg-[var(--colorBgContainer)] hover:bg-[var(--colorBgHover)] shadow-sm hover:shadow-md"),onClick:()=>ek(e.id),children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0 pr-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-2 min-w-0",children:[function(e,t){let r=ec[e]||(0,s.jsx)(_.A,{});return(0,s.jsx)("span",{style:{color:t?"var(--colorAccent)":"var(--colorTextSecondary)",fontSize:16,marginTop:2,flexShrink:0},children:r})}(e.category,eA===e.id),(0,s.jsx)("span",{className:"font-bold text-base text-[var(--colorText)] truncate",children:e.name}),eA===e.id&&(0,s.jsx)(u.A,{color:"blue",className:"border-0 m-0 shrink-0",children:"当前选中"}),(0,s.jsx)(u.A,{className:"border-0 bg-[var(--colorFillSecondary)] m-0 shrink-0",children:e.category})]}),e.description&&(0,s.jsx)("div",{className:"text-sm text-[var(--colorTextSecondary)] line-clamp-2 leading-relaxed mb-3",children:e.description}),(e=>{let t=ts[e.id];if(!t)return null;let r=t.issues.filter(e=>"error"===e.level),l=t.issues.filter(e=>"warning"===e.level),a=ta===e.id,n=t.roleDiagnostics||[],o=new Map;for(let e of t.promptDiagnostics){let t=o.get(e.roleId)||[];t.push(e),o.set(e.roleId,t)}let i=t.strategyPreview,c=(null==i?void 0:i.mode)==="strict"?"error":(null==i?void 0:i.mode)==="fast"?"blue":(null==i?void 0:i.mode)==="longform"?"purple":"green";return(0,s.jsxs)("div",{onClick:e=>e.stopPropagation(),className:"flex flex-col items-start gap-2 w-full",children:[(0,s.jsxs)("div",{className:"inline-flex items-center gap-2 p-1.5 px-3 rounded-lg border text-xs ".concat(r.length?"border-red-200 bg-red-50/50":l.length?"border-yellow-200 bg-yellow-50/50":"border-green-200 bg-green-50/50"),children:[(0,s.jsx)("span",{className:"font-medium",children:r.length?"检查未通过(".concat(r.length," 项阻断)"):l.length?"存在警告(".concat(l.length," 项)"):"检查通过"}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["项目资料 ",t.fileDiagnostics.length]}),(0,s.jsxs)("span",{children:["提示词 ",t.promptDiagnostics.length]}),(0,s.jsxs)("span",{children:["角色链路 ",n.length]}),i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)(u.A,{color:c,className:"border-0 m-0",children:[i.mode," 策略预估"]})]}),!r.length&&l.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsx)("span",{className:"text-blue-500 cursor-pointer hover:underline",onClick:()=>{re(e.id)},children:"忽略警告并运行"})]}),(0,s.jsxs)("span",{className:"text-blue-500 cursor-pointer hover:underline",onClick:()=>tn(a?null:e.id),children:[a?(0,s.jsx)(W.A,{}):(0,s.jsx)(G.A,{}),a?"收起体检":"体检报告"]})]}),a&&(0,s.jsxs)("div",{className:"w-full flex flex-col gap-3 rounded-xl border border-[var(--borderColor)] bg-[var(--colorBgContainer)] p-3",children:[r.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("span",{className:"text-xs font-bold text-[var(--colorError)]",children:["阻断项(",r.length,")— 必须修复后才能运行"]}),r.map(t=>{var r;let l=(r=t.message,/资料包|项目资料|知识库|索引/u.test(r)?{label:"配置模板",onClick:()=>t3(e)}:/提示词|绑定/u.test(r)?{label:"提示词库",href:"/prompt"}:/项目角色配置/u.test(r)?{label:"角色配置",href:"/document-roles"}:void 0);return(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50/40 px-2.5 py-1.5 text-xs",children:[(0,s.jsx)("span",{className:"text-[var(--colorText)]",children:t.message}),l&&(l.href?(0,s.jsxs)("a",{className:"shrink-0 text-red-500 hover:underline",href:l.href,children:[l.label," ›"]}):(0,s.jsxs)("span",{className:"shrink-0 text-red-500 cursor-pointer hover:underline",onClick:l.onClick,children:[l.label," ›"]}))]},t.message)})]}),l.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("span",{className:"text-xs font-bold text-[var(--colorWarning)]",children:["警告项(",l.length,")— 可忽略并继续运行"]}),l.map(e=>(0,s.jsx)("div",{className:"rounded-lg border border-yellow-200 bg-yellow-50/40 px-2.5 py-1.5 text-xs text-[var(--colorTextSecondary)]",children:e.message},e.message))]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("span",{className:"text-xs font-bold text-[var(--colorText)]",children:["绑定链路(",t.configName||"未绑定角色配置",")"]}),0===n.length?(0,s.jsx)("span",{className:"text-xs text-[var(--colorTextTertiary)]",children:"未配置提示词角色链路"}):(0,s.jsx)("div",{className:"flex flex-col gap-1.5",children:n.map(r=>{let l=o.get(r.roleId)||[];return(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs flex-wrap rounded-lg border border-[var(--borderColor)] bg-[var(--colorFillQuaternary)] px-2 py-1",children:[(0,s.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:e.name}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"→"}),(0,s.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:t.configName||"角色配置"}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"→"}),(0,s.jsx)("span",{className:"ok"===r.status?"text-[var(--colorText)]":"text-[var(--colorError)] font-medium",children:r.roleName||r.roleId}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"→"}),0===l.length?(0,s.jsx)(u.A,{color:"error",className:"border-0 m-0",children:"missing_resource"===r.status?"角色未绑定资源":"role_missing"===r.status?"角色不存在":"未绑定提示词"}):(0,s.jsx)("span",{className:"flex items-center gap-1 flex-wrap",children:l.map(e=>(0,s.jsx)(u.A,{color:e.exists&&e.contentLength>0?"success":e.exists?"warning":"error",className:"border-0 m-0",title:e.contentPreview||e.promptId,children:e.exists?"".concat(e.promptTitle||e.promptId," ").concat(e.contentLength,"字符"):"".concat(e.promptId," 已删除")},e.promptId))})]},r.roleId)})})]}),i&&(0,s.jsxs)("div",{className:"flex flex-col gap-1 rounded-lg border border-blue-200 bg-blue-50/40 px-2.5 py-2 text-xs",children:[(0,s.jsx)("span",{className:"font-bold text-[var(--colorText)]",children:"生成策略预估(生成前体检)"}),(0,s.jsxs)("span",{className:"text-[var(--colorTextSecondary)]",children:["约 ",i.chapterCount," 章 / 目标 ",i.targetWords>=1e4?"".concat((i.targetWords/1e4).toFixed(1)," 万字"):"".concat(i.targetWords," 字"),";全章节并行(",i.chapterConcurrency," 章同批);审查流水线 ",i.reviewConcurrency," 路;每章证据预算 ",Math.round(i.evidenceFloorChars/1e3),"k-",Math.round(i.evidenceCeilingChars/1e3),"k 字符;修复轮次预算 ",i.repairRoundBudget," 轮",i.globalReviewSamplingRate<1?";全局审查抽检 ".concat(Math.round(100*i.globalReviewSamplingRate),"%"):""]}),i.triggers.map(e=>(0,s.jsxs)("span",{className:"text-[var(--colorTextTertiary)]",children:["\xb7 ",e]},e))]})]})]})})(e)]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-nowrap items-center gap-2 whitespace-nowrap transition-opacity ".concat(eA===e.id?"opacity-100":"opacity-0 group-hover:opacity-100"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(m.Ay,{size:"small",onClick:t=>{t.stopPropagation(),t3(e)},className:"rounded-md",children:"配置"}),(0,s.jsx)(m.Ay,{size:"small",icon:(0,s.jsx)(H.A,{}),onClick:t=>{t.stopPropagation(),t7(e.id)},className:"rounded-md"}),(0,s.jsx)(er,{title:ev("documents.deleteTemplateConfirm"),onConfirm:t=>{null==t||t.stopPropagation(),t9(e.id)},children:(0,s.jsx)(m.Ay,{size:"small",danger:!0,icon:(0,s.jsx)(q.A,{}),onClick:e=>e.stopPropagation(),className:"rounded-md"})}),(()=>{var t;let r=ts[e.id],l=null!=(t=null==r?void 0:r.issues.filter(e=>"error"===e.level).length)?t:0;return l>0?(0,s.jsxs)(m.Ay,{size:"small",danger:!0,icon:(0,s.jsx)(U.A,{}),disabled:!!tz&&tz!==e.id,onClick:t=>{var r;t.stopPropagation(),ek(r=e.id),tn(r),window.setTimeout(()=>{var e;return null==(e=to.current[r])?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})},50)},className:"min-w-[108px] rounded-md justify-center",children:["先修复 ",l," 个问题"]}):(0,s.jsx)(m.Ay,{size:"small",type:"primary",icon:tz===e.id?(0,s.jsx)(B.A,{}):(0,s.jsx)(V.A,{}),loading:tz===e.id,disabled:!!tz&&tz!==e.id,onClick:t=>{t.stopPropagation(),re(e.id)},className:"min-w-[72px] rounded-md justify-center",children:tz===e.id?"准备中":"运行"})})()]})]},e.id))}):0===eO.length?(0,s.jsx)("div",{className:"py-32 text-center border border-dashed border-[var(--borderColor)] rounded-2xl bg-[var(--colorBgContainer)]",children:(0,s.jsx)(h.A,{description:(0,s.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:ev("common.noData")})})}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4",children:eO.slice(0,15).map((e,t)=>{var r,l,a,n,o,i,c,d,p,x;let h,g;return(0,s.jsxs)("div",{className:"group flex items-center gap-4 p-4 rounded-2xl transition-all cursor-pointer ".concat(eU===e.id?"bg-[var(--colorBgSelected)] shadow-md":"bg-[var(--colorBgContainer)] hover:bg-[var(--colorBgHover)] shadow-sm hover:shadow-md"),onClick:()=>{tQ(e)},children:[(0,s.jsx)("div",{className:"mt-1",children:"completed"===e.status?(0,s.jsx)(P.A,{className:"text-xl text-[var(--colorOk)]"}):"failed"===e.status||"aborted"===e.status?(0,s.jsx)(L.A,{className:"text-xl text-[var(--colorDanger)]"}):"warning"===e.status||"completed_with_issues"===e.status?(0,s.jsx)(M.A,{className:"text-xl text-[var(--colorWarning)]"}):(0,s.jsx)(K.A,{spin:!0,className:"text-xl text-blue-500"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 pr-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,s.jsx)("span",{className:"font-bold text-base text-[var(--colorText)] truncate",children:e.title}),(0,s.jsxs)(u.A,{className:"border-0 bg-[var(--colorFillSecondary)] m-0 shrink-0",children:["#",t+1]}),(0,s.jsxs)(u.A,{color:"completed"===(h=e.status)?"success":"completed_with_issues"===h||"warning"===h?"warning":"failed"===h?"error":"aborted"===h||"queued"===h?"default":"processing",className:"border-0 m-0 shrink-0",children:["completed"===(g=e.status)?"已完成":"completed_with_issues"===g?"已完成(待复核)":"warning"===g?"需复核":"failed"===g?"失败":"aborted"===g?"已中止":"queued"===g?"排队中":"生成中","queued"===e.status&&e.queuePosition?"(第 ".concat(e.queuePosition," 位)"):""]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-2 text-xs text-[var(--colorTextSecondary)] mb-3",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(Q.A,{})," ",new Date(e.updatedAt).toLocaleString()]}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["耗时 ",(e=>{let t=Math.max(0,Math.round(((e.completedAt||e.updatedAt)-e.createdAt)/1e3));if(t<60)return"".concat(t," 秒");let r=Math.floor(t/60),s=t%60;if(r<60)return s?"".concat(r," 分 ").concat(s," 秒"):"".concat(r," 分");let l=Math.floor(r/60),a=r%60;return a?"".concat(l," 小时 ").concat(a," 分"):"".concat(l," 小时")})(e)]}),e.partialChapters&&e.partialChapters.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["进度 ",e.partialChapters.filter(e=>"completed"===e.status).length,"/",e.partialChapters.length," 章"]}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["共 ",e.partialChapters.reduce((e,t)=>e+t.chars,0).toLocaleString()," 字"]})]})]}),("warning"===e.status||"failed"===e.status||"aborted"===e.status)&&(0,s.jsxs)("div",{className:"inline-flex items-center gap-2 p-1.5 px-3 rounded-lg border text-xs ".concat("failed"===e.status||"aborted"===e.status?"border-red-200 bg-red-50/50":"border-yellow-200 bg-yellow-50/50"),children:[(0,s.jsx)("span",{className:"font-medium",children:"failed"===e.status?(null==(l=e.draft)||null==(r=l.exportGate)?void 0:r.passed)===!1?"门禁未通过":"生成失败":"aborted"===e.status?"已中止":"需复核"}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsx)("span",{className:"truncate max-w-[400px]",children:e.error||(null==(a=e.warningIssues)?void 0:a[0])||(null==(o=e.draft)||null==(n=o.validationIssues.find(e=>"error"===e.level||"warning"===e.level))?void 0:n.message)||(null==(d=e.draft)||null==(c=d.exportGate)||null==(i=c.checklist.find(e=>!e.passed))?void 0:i.label)||"需复核"})]})]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-nowrap items-center gap-2 whitespace-nowrap transition-opacity ".concat(eU===e.id?"opacity-100":"opacity-0 group-hover:opacity-100"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(m.Ay,{size:"small",type:"primary",icon:tX(e.status)?(0,s.jsx)(K.A,{spin:!0}):(0,s.jsx)(V.A,{}),onClick:t=>{t.stopPropagation(),tQ(e)},className:"min-w-[72px] rounded-md justify-center",children:"打开"}),tX(e.status)&&(0,s.jsx)(er,{title:"queued"===e.status?"确定取消此排队任务?":"确定中止此生成任务?",onConfirm:t=>{null==t||t.stopPropagation(),rn(e)},children:(0,s.jsx)(m.Ay,{size:"small",danger:!0,onClick:e=>e.stopPropagation(),className:"rounded-md",children:"queued"===e.status?"取消":"中止"})}),("failed"===e.status||"aborted"===e.status||"warning"===e.status&&!!(null==(p=e.checkpointChapters)?void 0:p.length)&&/继续生成|重新生成|中断|卡住|未完成/u.test(e.error||(null==(x=e.warningIssues)?void 0:x.join(";"))||""))&&(0,s.jsx)(m.Ay,{size:"small",onClick:t=>{t.stopPropagation(),ra(e)},className:"rounded-md",children:"继续"}),(0,s.jsx)(er,{title:"确认删除?",onConfirm:t=>{null==t||t.stopPropagation(),rt(e)},children:(0,s.jsx)(m.Ay,{size:"small",danger:!0,icon:(0,s.jsx)(q.A,{}),onClick:e=>e.stopPropagation(),className:"rounded-md"})})]})]},e.id)})})})]}),(0,s.jsx)(g.A,{title:rv,open:tb,onClose:()=>{for(let e of(tA(!1),tF.current.values()))clearInterval(e);tF.current.clear()},size:"large",mask:{closable:!1},style:{borderRadius:"12px 0 0 12px"},styles:{body:{padding:"16px 24px"},header:{borderRadius:"12px 0 0 0",borderBottom:"1px solid var(--colorBorderSecondary)"}},extra:eq?(0,s.jsxs)(i.A,{wrap:!0,children:[tJ(tf)&&(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(V.A,{}),disabled:eY||eB,onClick:()=>{tf&&ra(tf)},children:"继续生成"}),(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(X.A,{}),disabled:eY,onClick:()=>{ru()},children:ev("documents.saveDraft")}),(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(J.A,{}),disabled:eY,loading:"markdown"===eK,onClick:()=>{ri("markdown")},children:"MD"}),(0,s.jsx)(m.Ay,{disabled:eY,loading:"html"===eK,onClick:()=>{ri("html")},children:"HTML"}),(0,s.jsx)(m.Ay,{disabled:eY,loading:"docx"===eK,onClick:()=>{ri("docx")},children:"DOCX"}),(0,s.jsx)(m.Ay,{type:"primary",disabled:eY,loading:"pdf"===eK,onClick:()=>{ri("pdf")},children:"PDF"})]}):tJ(tf)||rc()||eB&&"workflow"===tk?(0,s.jsxs)(i.A,{wrap:!0,children:[tJ(tf)&&(0,s.jsx)(m.Ay,{type:"primary",icon:(0,s.jsx)(V.A,{}),loading:eB,onClick:()=>{tf&&ra(tf)},children:"继续生成"}),rc()&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(J.A,{}),loading:"markdown"===eK,onClick:()=>{rd("markdown")},children:"MD"}),(0,s.jsx)(m.Ay,{loading:"html"===eK,onClick:()=>{rd("html")},children:"HTML"}),(0,s.jsx)(m.Ay,{loading:"docx"===eK,onClick:()=>{rd("docx")},children:"DOCX"}),(0,s.jsx)(m.Ay,{type:"primary",loading:"pdf"===eK,onClick:()=>{rd("pdf")},children:"PDF"})]}),eB&&"workflow"===tk&&(0,s.jsx)(m.Ay,{danger:!0,onClick:()=>{(async()=>{if(ea&&(en=!0),eU&&await (0,Y.r)(eU,tm||void 0).catch(()=>void 0),ea){var e;ea.aborted=!0,null==(e=ea.pollController)||e.abort(),ea.loading=!1,ea.error="用户中止",eo(),ea=null}for(let e of(localStorage.removeItem(tq),tF.current.values()))clearInterval(e);tF.current.clear(),eP(!1),th([]),tv(null),tA(!1),await tL(),ef.info("已中止生成任务")})()},children:"中止任务"})]}):void 0,children:(0,s.jsxs)(el,{style:{width:"100%"},gap:16,children:["workflow"===tk&&tx.length>0&&(0,s.jsx)(el,{gap:10,children:tx.map((e,t)=>{let r=tC.has(e.key),l=e.subSteps.length>8||e.description.length>240;return(0,s.jsxs)("div",{style:{display:"flex",gap:10,padding:10,border:"1px solid var(--colorBorderSecondary)",borderRadius:10,background:t===tO?"var(--colorFillAlter)":"var(--colorBgContainer)"},children:[(0,s.jsx)("span",{children:"process"===e.status?(0,s.jsx)(B.A,{}):"warning"===e.status?(0,s.jsx)(M.A,{style:{color:"var(--colorWarning)"}}):e.icon}),(0,s.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,s.jsxs)(i.A,{wrap:!0,children:[(0,s.jsx)(et,{strong:!0,children:e.title}),(0,s.jsx)(u.A,{color:"finish"===e.status?"success":"error"===e.status?"error":"warning"===e.status?"warning":"process"===e.status?"processing":"default",children:ev(ex[e.status])}),(e=>{var t;let r=ti.current.get(e.key);if(!r)return null;let l=t1((null!=(t=r.endedAt)?t:Date.now())-r.startedAt);return(0,s.jsx)(u.A,{className:"border-0 bg-[var(--colorFillSecondary)] m-0",children:r.endedAt?l:"".concat(l,"(运行中)")})})(e)]}),(0,s.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12,whiteSpace:"pre-wrap"},children:((e,t)=>{let r=e.description.length>240,l=t?e.subSteps:e.subSteps.slice(0,8);return(0,s.jsxs)("div",{children:[e.subtitle&&(0,s.jsx)("div",{style:{marginBottom:4},children:(0,s.jsx)(u.A,{children:e.subtitle})}),(0,s.jsx)("div",{style:!t&&r?{display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"}:void 0,children:e.description}),(0,s.jsx)("div",{style:{marginTop:4},children:l.map(e=>{var t;return(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"process"===e.status?"var(--colorPrimary)":"var(--colorTextSecondary)"},children:["process"===(t=e.status)?(0,s.jsx)(B.A,{}):"finish"===t?(0,s.jsx)(P.A,{}):"warning"===t?(0,s.jsx)(M.A,{style:{color:"var(--colorWarning)"}}):"error"===t?(0,s.jsx)(q.A,{}):(0,s.jsx)("span",{style:{display:"inline-block",height:6,width:6,borderRadius:"50%",background:"var(--colorTextTertiary)"}}),(0,s.jsx)("span",{children:e.title})]},e.key)})})]})})(e,r)}),l&&(0,s.jsx)(m.Ay,{size:"small",type:"link",style:{padding:0,height:"auto",marginTop:6},onClick:()=>{var t;return t=e.key,void tN(e=>{let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r})},children:r?"收起":e.subSteps.length>8?"更多(".concat(e.subSteps.length," 条详情)"):"更多"})]})]},e.key)})}),"workflow"===tk&&(null==tf?void 0:tf.partialChapters)&&tf.partialChapters.length>0&&(0,s.jsx)(v.A,{size:"small",title:"章节进度",extra:(0,s.jsxs)(u.A,{color:"blue",children:[tf.partialChapters.filter(e=>"completed"===e.status).length,"/",tf.partialChapters.length]}),children:(0,s.jsx)(el,{gap:6,style:{width:"100%"},children:tf.partialChapters.map(e=>(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:8,fontSize:12},children:[(0,s.jsx)(et,{ellipsis:!0,style:{maxWidth:480},children:e.title}),(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(u.A,{color:"failed"===e.status?"error":"success",children:"failed"===e.status?"失败":"完成"}),(0,s.jsxs)(et,{type:"secondary",children:[e.chars.toLocaleString()," 字"]})]})]},e.id))})}),"workflow"===tk&&(null==tf||null==(t=tf.draft)||null==(e=t.exportGate)?void 0:e.passed)===!1&&(()=>{var e;let t=(null==(e=tf.draft.exportGate.blockingIssues)?void 0:e.map(e=>e.message))||tf.draft.exportGate.checklist.filter(e=>!e.passed).map(e=>e.label)||["存在阻断级校验错误"],r=tI?t:t.slice(0,6);return(0,s.jsx)(es,{type:"error",title:"生成已完成,但导出门禁未通过",children:(0,s.jsxs)(i.A,{direction:"vertical",size:8,style:{width:"100%"},children:[(0,s.jsx)("span",{children:"阻断项:".concat(r.join(";")).concat(t.length>6&&!tI?"…(共 ".concat(t.length," 项)"):"","。可点击继续生成触发自动修复,或在“校验”页查看完整问题。")}),t.length>6&&(0,s.jsx)(m.Ay,{size:"small",type:"link",style:{padding:0,height:"auto",alignSelf:"flex-start"},onClick:()=>tT(e=>!e),children:tI?"收起":"查看全部 ".concat(t.length," 项")}),tJ(tf)&&(0,s.jsx)(m.Ay,{type:"primary",size:"small",icon:(0,s.jsx)(V.A,{}),loading:eB,onClick:()=>{ra(tf)},children:"继续生成 / 自动修复"})]})})})(),"workflow"===tk&&(null==tf||null==(r=tf.reviewMetadata)?void 0:r.diagnostics)&&(0,s.jsx)(es,{type:"info",title:"后台自动优化",children:"策略:".concat(tf.reviewMetadata.diagnostics.strategy.mode,";LLM 调用 ").concat(tf.reviewMetadata.diagnostics.llm.calls," 次;噪声过滤 ").concat((null==(a=tf.reviewMetadata.diagnostics.evidence)?void 0:a.filteredNoise)||0," 条;质量门禁 阻断").concat((null==(o=tf.reviewMetadata.diagnostics.quality)?void 0:o.blockingCount)||0,"/重要").concat((null==(E=tf.reviewMetadata.diagnostics.quality)?void 0:E.importantCount)||0,"/轻微").concat((null==(F=tf.reviewMetadata.diagnostics.quality)?void 0:F.minorCount)||0,";自动限流调整 ").concat(tf.reviewMetadata.diagnostics.llm.limitAdjustments," 次。审查与诊断信息仅用于系统修复,不会写入正文或导出文件。")}),"workflow"===tk&&(null==tf||null==(D=tf.draft)?void 0:D.promptRules)&&(()=>{let e=tf.draft.promptRules,t=e.executionSummary||[],r=Object.entries(e.ruleSources||{}).filter(e=>{let[,t]=e;return t.length>0}),l=r.length>0,a=tR?r:r.slice(0,3);return(0,s.jsx)(v.A,{size:"small",title:(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(M.A,{style:{color:"var(--colorAccent)"}}),"提示词规则生效报告",t.length>0&&(0,s.jsxs)(u.A,{style:{margin:0},children:[t.length," 条"]})]}),styles:{body:{padding:12}},children:(0,s.jsxs)(el,{gap:6,children:[t.length>0&&t.map((e,t)=>(0,s.jsxs)("div",{style:{display:"flex",gap:6,fontSize:12,color:"var(--colorText)",lineHeight:1.6},children:[(0,s.jsx)(P.A,{style:{color:"var(--colorSuccess)",marginTop:4}}),(0,s.jsx)("span",{children:e})]},t)),l&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f.A,{style:{margin:"4px 0"}}),(0,s.jsx)(et,{type:"secondary",style:{fontSize:12},children:"规则溯源(自动从以下提示词中抽取):"}),a.map(e=>{let[t,r]=e;return(0,s.jsxs)("div",{style:{fontSize:12,color:"var(--colorTextSecondary)",lineHeight:1.6},children:[(0,s.jsx)(et,{strong:!0,style:{fontSize:12},children:t}),":",r.map(e=>"".concat(e.roleId,"「").concat(e.matchedText.length>24?"".concat(e.matchedText.slice(0,24),"…"):e.matchedText,"」")).join("、")]},t)}),r.length>3&&(0,s.jsx)(m.Ay,{size:"small",type:"link",style:{padding:0,height:"auto",alignSelf:"flex-start"},onClick:()=>tM(e=>!e),children:tR?"收起溯源":"查看全部溯源(".concat(r.length," 类)")})]}),!l&&0===t.length&&(0,s.jsx)(et,{type:"secondary",style:{fontSize:12},children:"未从提示词中识别到额外硬规则,使用系统默认质量规则。"})]})})})(),"workflow"===tk&&eB&&0===tx.length&&(0,s.jsxs)("div",{style:{textAlign:"center",padding:40},children:[(0,s.jsx)(j.A,{}),(0,s.jsx)("div",{style:{marginTop:12,color:"var(--colorTextSecondary)"},children:"正在准备生成…"})]}),"editor"===tk&&(null==eq?void 0:eq.reviewMetadata)&&(()=>{var e;let t=null==(e=eq.reviewMetadata.diagnostics)?void 0:e.quality,r=(eq.executionStages||[]).filter(e=>"llm_review"===e.type).flatMap(e=>(e.details||[]).filter(e=>/修复|补写|补齐|改进|调整/u.test(e))).slice(0,8);return t||0!==r.length?(0,s.jsx)(v.A,{size:"small",title:(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(P.A,{style:{color:"var(--colorSuccess)"}}),"运行质量报告"]}),styles:{body:{padding:12}},children:(0,s.jsxs)(el,{gap:8,children:[t&&(0,s.jsx)(i.A,{wrap:!0,size:6,children:(0,s.jsxs)(u.A,{color:t.blockingCount>0?"error":"success",className:"border-0 m-0",children:["审查修复 ",t.repairedCount," 项 / 问题 ",t.blockingCount+t.importantCount+t.minorCount," 项"]})}),r.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-1 rounded-lg border border-[var(--borderColor)] bg-[var(--colorFillQuaternary)] px-3 py-2",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-[var(--colorText)]",children:"修复记录(审查阶段自动修复的内容)"}),r.map((e,t)=>(0,s.jsxs)("span",{className:"text-xs text-[var(--colorTextSecondary)]",children:["\xb7 ",e]},t))]})]})}):null})(),"editor"===tk&&tu.length>0&&(0,s.jsx)(v.A,{size:"small",title:(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(J.A,{}),"导出闭环报告",(0,s.jsx)(u.A,{className:"border-0 bg-[var(--colorFillSecondary)] m-0",children:tu.length})]}),styles:{body:{padding:12}},children:(0,s.jsxs)(el,{gap:6,children:[[...tu].reverse().map((e,t)=>(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-[var(--borderColor)] bg-[var(--colorFillQuaternary)] px-3 py-2 text-xs",children:[(0,s.jsx)(et,{strong:!0,children:e.format.toUpperCase()}),(0,s.jsx)(u.A,{color:"blue",className:"border-0 m-0",children:new Date(e.exportedAt).toLocaleString()}),void 0!==e.durationMs&&(0,s.jsxs)("span",{className:"text-[var(--colorTextSecondary)]",children:["总用时 ",t1(e.durationMs)]}),void 0!==e.repairedCount&&(0,s.jsxs)("span",{className:"text-[var(--colorTextSecondary)]",children:["修复 ",e.repairedCount," 项",void 0!==e.blockingCount?"(阻断 ".concat(e.blockingCount,")"):""]}),e.ruleSummary&&e.ruleSummary.length>0&&(0,s.jsxs)("span",{className:"text-[var(--colorTextSecondary)]",children:["规则 ",e.ruleSummary.length," 条"]}),!1===e.gatePassed&&(0,s.jsx)(u.A,{color:"error",className:"border-0 m-0",children:"门禁未过"}),e.healthAlerts&&e.healthAlerts.length>0&&(0,s.jsxs)(u.A,{color:"warning",className:"border-0 m-0",children:["健康告警 ",e.healthAlerts.length]})]},"".concat(e.exportedAt,"-").concat(t))),(()=>{let e=function(e){let t=[],r=[];if(e.length<3)return{retireCandidates:t,constraintSuggestions:r};let s=[...e].sort((e,t)=>e.exportedAt-t.exportedAt),l=s.slice(-3),a=s.slice(0,-3),n=new Set;for(let e of[...a,...l])for(let t of Object.keys(e.repairHeat||{}))n.add(t);for(let e of n){let s=l.map(t=>{var r;return null==(r=t.repairHeat)?void 0:r[e]});if(a.some(t=>{var r,s,l;return(null!=(l=null==(s=t.repairHeat)||null==(r=s[e])?void 0:r.hits)?l:0)>0})&&s.every(e=>void 0!==e&&0===e.hits)&&t.push(e),s.every(e=>void 0!==e&&e.hits>0&&e.failed/e.hits>=.5)){let t=s.reduce((e,t)=>e+(t?t.failed/t.hits:0),0)/s.length;r.push("".concat(e,"|").concat((100*t).toFixed(0),"%|连续").concat(3,"次"))}}return{retireCandidates:t,constraintSuggestions:r}}(tu);return 0===e.retireCandidates.length&&0===e.constraintSuggestions.length?null:(0,s.jsxs)(es,{type:"info",title:"跨文档缺陷热力图",children:[e.retireCandidates.length>0&&(0,s.jsxs)("div",{children:["候选退役(连续 3 次零命中,可评估停用):",e.retireCandidates.map(e=>{let t=e.split("|")[0];return $[t]?"".concat($[t],"(").concat(e,")"):e}).join("、")]}),e.constraintSuggestions.length>0&&(0,s.jsxs)("div",{children:["建议加入写作硬约束(高命中且修复失败率高):",e.constraintSuggestions.map(e=>{let t=e.split("|")[0];return $[t]?"".concat($[t],"(").concat(e,")"):e}).join("、")]})]})})()]})}),eq&&(0,s.jsx)("div",{ref:ey,children:(0,s.jsx)(x.A,{items:[{key:"edit",label:ev("documents.edit"),children:(0,s.jsxs)(el,{gap:16,style:{width:"100%"},children:[(0,s.jsx)(ee,{rows:28,value:eW,disabled:eY,onSelect:e=>{var t,r,s;return e3({start:null!=(t=e.currentTarget.selectionStart)?t:0,end:null!=(s=null!=(r=e.currentTarget.selectionEnd)?r:e.currentTarget.selectionStart)?s:0})},onChange:e=>{var t,r,s;eG(e.target.value),e2(null),e5(null),e3({start:null!=(t=e.target.selectionStart)?t:0,end:null!=(s=null!=(r=e.target.selectionEnd)?r:e.target.selectionStart)?s:0})}}),(0,s.jsx)(v.A,{size:"small",style:{borderRadius:12,background:"linear-gradient(135deg, var(--colorFillAlter), var(--colorBgContainer))"},children:(0,s.jsxs)(el,{gap:16,style:{width:"100%"},children:[(0,s.jsxs)(i.A,{align:"start",style:{width:"100%",justifyContent:"space-between"},children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(z.A,{style:{color:"var(--colorAccent)"}}),(0,s.jsx)(et,{strong:!0,children:"精准修改"}),(0,s.jsx)(u.A,{color:"blue",children:"AI 辅助"})]}),(0,s.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12},children:"针对当前编辑内容补充更具体的要求,AI 会保留文档结构并按你的提示细化修改。"})]}),(0,s.jsxs)(m.Ay,{size:"small",icon:(0,s.jsx)(Q.A,{}),onClick:()=>te(e=>!e),disabled:0===e4.length,children:["历史版本 ",e4.length>0?e4.length:""]})]}),(0,s.jsx)(es,{type:"info",title:"系统只负责识别修改范围,不改写你的提示词;选中文字后优先只改选区,没有选区时按光标所在小节/章节定位。"}),(0,s.jsx)(ee,{rows:4,value:eX,disabled:eY,onChange:e=>{eJ(e.target.value),e2(null),e5(null)},placeholder:"例如:写细一点;润色这段;第七章补充高处作业和临电安全措施;把安全检查频次改成每周一次。"}),(0,s.jsxs)(i.A,{wrap:!0,style:{width:"100%",justifyContent:"space-between"},children:[(0,s.jsx)(i.A,{wrap:!0,children:["写细一点","更专业","只润色选区","补充可执行措施"].map(e=>(0,s.jsx)(m.Ay,{size:"small",disabled:eY,onClick:()=>eJ(t=>t?"".concat(t,";").concat(e):e),children:e},e))}),(0,s.jsx)(m.Ay,{type:"primary",icon:(0,s.jsx)(z.A,{}),loading:eY&&"planning"===e$,disabled:!eX.trim()||eY,onClick:()=>{rh()},children:"识别修改范围"})]}),e1&&!e6&&(0,s.jsx)(v.A,{size:"small",style:{borderRadius:10,borderColor:"var(--colorAccent)"},children:(0,s.jsxs)(el,{gap:8,style:{width:"100%"},children:[(0,s.jsxs)(i.A,{wrap:!0,children:[(0,s.jsx)(u.A,{color:"purple",children:e1.scope}),(0,s.jsx)(u.A,{color:"blue",children:e1.action}),(0,s.jsxs)(u.A,{color:e1.confidence>=.8?"green":"orange",children:["置信度 ",Math.round(100*e1.confidence),"%"]}),e1.targetTitle&&(0,s.jsx)(et,{strong:!0,children:e1.targetTitle})]}),(0,s.jsx)(et,{children:e1.summary}),(0,s.jsx)(et,{type:"secondary",style:{fontSize:12},children:"将按你的原始提示词执行,不添加额外编辑任务。"}),(0,s.jsxs)(i.A,{children:[(0,s.jsx)(m.Ay,{type:"primary",loading:eY&&"applying"===e$,onClick:()=>{rg(e1)},children:"执行并预览"}),(0,s.jsx)(m.Ay,{disabled:eY,onClick:()=>e2(null),children:"取消"})]})]})}),e6&&(0,s.jsx)(v.A,{size:"small",style:{borderRadius:10,borderColor:"var(--colorSuccess)"},children:(0,s.jsxs)(el,{gap:8,style:{width:"100%"},children:[(0,s.jsxs)(i.A,{wrap:!0,children:[(0,s.jsx)(u.A,{color:"green",children:"修改预览"}),(0,s.jsx)(et,{children:e6.summary||e6.plan.summary}),(0,s.jsxs)(u.A,{children:[e6.changedChars&&e6.changedChars>0?"+".concat(e6.changedChars):e6.changedChars," 字符"]})]}),(0,s.jsxs)(y.A,{gutter:12,children:[(0,s.jsxs)(w.A,{span:12,children:[(0,s.jsx)(et,{strong:!0,children:"修改前"}),(0,s.jsx)("div",{style:{marginTop:6,maxHeight:180,overflow:"auto",padding:10,borderRadius:8,background:"var(--colorFillAlter)",whiteSpace:"pre-wrap",fontSize:12},children:e6.beforeSnippet||"无片段预览"})]}),(0,s.jsxs)(w.A,{span:12,children:[(0,s.jsx)(et,{strong:!0,children:"修改后"}),(0,s.jsx)("div",{style:{marginTop:6,maxHeight:180,overflow:"auto",padding:10,borderRadius:8,background:"var(--colorFillAlter)",whiteSpace:"pre-wrap",fontSize:12},children:e6.afterSnippet||"无片段预览"})]})]}),(0,s.jsxs)(i.A,{children:[(0,s.jsx)(m.Ay,{type:"primary",onClick:()=>{e6&&(rp(e6.before,e6.prompt),eG(e6.markdown),rm(!0),ef.success("已应用精准修改"))},children:"应用到文档"}),(0,s.jsx)(m.Ay,{onClick:()=>e5(null),children:"返回计划"}),(0,s.jsx)(m.Ay,{danger:!0,onClick:()=>{e2(null),e5(null)},children:"放弃"})]})]})}),e9&&(0,s.jsx)("div",{style:{borderTop:"1px solid var(--colorBorderSecondary)",paddingTop:12},children:(0,s.jsx)(b.A,{size:"small",dataSource:e4,locale:{emptyText:"暂无历史版本"},renderItem:e=>(0,s.jsx)(b.A.Item,{actions:[(0,s.jsx)(m.Ay,{size:"small",disabled:eY,onClick:()=>{rp(eW,"恢复前版本"),eG(e.content),rm(!0),ef.success("已恢复历史版本")},children:"恢复"},"restore")],children:(0,s.jsx)(b.A.Item.Meta,{title:(0,s.jsxs)(i.A,{children:[(0,s.jsx)(et,{children:new Date(e.createdAt).toLocaleString()}),(0,s.jsx)(u.A,{children:e.prompt})]}),description:(0,s.jsx)(et,{type:"secondary",ellipsis:!0,children:e.content.replace(/\s+/gu," ").slice(0,120)})})})})})]})})]})},{key:"chapters-facts",label:"章节与事实",children:(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[eq.chapters.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsxs)(et,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["章节 (",eq.chapters.length,")"]}),(0,s.jsx)(b.A,{size:"small",dataSource:eq.chapters,renderItem:e=>(0,s.jsx)(b.A.Item,{children:(0,s.jsx)(b.A.Item.Meta,{title:e.title,description:"证据: ".concat(e.evidence.length," \xb7 缺失: ").concat(e.missingFacts.length)})})})]}),eq.structuredFacts.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsxs)(et,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["结构化事实 (",eq.structuredFacts.length,")"]}),(0,s.jsx)(A.A,{size:"small",column:1,bordered:!0,children:eq.structuredFacts.map((e,t)=>(0,s.jsxs)(A.A.Item,{label:e.key,children:[(0,s.jsx)("span",{children:e.value}),(0,s.jsx)(u.A,{style:{marginLeft:8},children:e.confidence.toFixed(2)}),(0,s.jsx)(et,{type:"secondary",style:{fontSize:11,marginLeft:8},children:e.sourceFile})]},t))})]})]})},{key:"sources-missing",label:"来源与缺失",children:(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(et,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["引用来源 (",eq.sources.length,")"]}),0===eq.sources.length?(0,s.jsx)(h.A,{description:"暂无"}):(0,s.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:eq.sources.map(e=>(0,s.jsxs)(u.A,{color:"blue",children:[e.filePath," (",e.count,")"]},e.filePath))})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)(et,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["缺失项 (",eq.missingItems.length,")"]}),0===eq.missingItems.length?(0,s.jsx)(h.A,{description:"无缺失"}):(0,s.jsx)(b.A,{size:"small",dataSource:eq.missingItems,renderItem:e=>(0,s.jsx)(b.A.Item,{children:e})})]})]})},{key:"validation",label:"校验 (".concat(eq.validationIssues.length,")"),children:0===eq.validationIssues.length?(0,s.jsx)(h.A,{description:"校验通过"}):(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[eq.validationIssues.map(e=>(0,s.jsxs)("div",{style:{border:"1px solid var(--colorBorderSecondary)",borderRadius:8,padding:12},children:[(0,s.jsx)(u.A,{color:"error"===e.level?"error":"warning"===e.level?"warning":"blue",children:ev(eg[e.level])}),(0,s.jsx)("div",{style:{marginTop:6,whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-all",lineHeight:1.6},children:e.message}),e.suggestion&&(0,s.jsx)("div",{style:{marginTop:6,color:"var(--colorTextSecondary)",whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-all"},children:e.suggestion})]},"".concat(e.level,"-").concat(e.message))),eq.exportGate.checklist.length>0&&(0,s.jsxs)("div",{style:{marginTop:8},children:[(0,s.jsx)(et,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:"导出门禁"}),(0,s.jsx)(b.A,{size:"small",dataSource:eq.exportGate.checklist,renderItem:e=>(0,s.jsxs)(b.A.Item,{children:[(0,s.jsx)(et,{style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:e.label}),(0,s.jsx)(u.A,{color:e.passed?"success":"error",children:e.passed?"PASS":"FAIL"})]})})]})]})},{key:"stages",label:"执行阶段 (".concat(eq.executionStages.length,")"),children:(0,s.jsx)(b.A,{size:"small",dataSource:eq.executionStages,renderItem:e=>(0,s.jsxs)(b.A.Item,{children:[(0,s.jsx)(b.A.Item.Meta,{avatar:ei[e.type]||(0,s.jsx)(_.A,{}),title:(0,s.jsx)(et,{title:e.roleId,style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:"".concat(e.title||ep[e.type]||e.type," \xb7 ").concat(e.roleName||e.subtitle||tH(e.roleId))}),description:(0,s.jsx)(et,{type:"secondary",style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},children:e.message})}),(0,s.jsx)(u.A,{color:"success"===e.status?"success":"failed"===e.status?"error":"skipped"===e.status?"default":"warning",children:ev(eh[e.status])})]})})}]})})]})}),(0,s.jsx)(g.A,{title:ev("documents.templateEditor"),open:tt,onClose:()=>tr(!1),size:"large",mask:{closable:!1},styles:{body:{padding:20,overflow:"auto"},header:{borderBottom:"1px solid var(--colorBorderSecondary)"}},extra:(0,s.jsxs)(i.A,{children:[(0,s.jsx)(m.Ay,{onClick:()=>tr(!1),children:ev("common.cancel")}),(0,s.jsx)(m.Ay,{type:"primary",onClick:()=>{t4()},children:ev("common.save")})]}),children:(0,s.jsxs)(d.A,{form:ej,layout:"vertical",requiredMark:"optional",children:[(0,s.jsxs)(y.A,{gutter:12,children:[(0,s.jsx)(d.A.Item,{name:"id",hidden:!0,children:(0,s.jsx)(n.A,{})}),(0,s.jsx)(w.A,{xs:24,md:8,children:(0,s.jsx)(d.A.Item,{name:"name",label:ev("documents.templateName"),rules:[{required:!0}],children:(0,s.jsx)(n.A,{})})}),(0,s.jsx)(w.A,{xs:24,md:8,children:(0,s.jsx)(d.A.Item,{name:"category",label:ev("documents.templateCategory"),children:(0,s.jsx)(n.A,{})})}),(0,s.jsx)(w.A,{xs:24,md:8,children:(0,s.jsx)(d.A.Item,{name:"outputTitle",label:ev("documents.outputTitle"),children:(0,s.jsx)(n.A,{})})}),(0,s.jsx)(w.A,{xs:24,md:12,children:(0,s.jsx)(d.A.Item,{name:"description",label:ev("documents.templateDescription"),children:(0,s.jsx)(n.A,{})})})]}),(0,s.jsx)(d.A.Item,{name:"projectRoleConfigId",label:ev("documents.projectRoleConfig"),rules:[{required:!0,message:ev("documents.projectRoleConfigRequired")}],children:(0,s.jsx)(k.A,{showSearch:!0,placeholder:ev("documents.projectRoleConfigRequired"),options:tG})}),(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(et,{strong:!0,className:"text-base text-[var(--colorText)] block mb-1",children:"项目资料包绑定"}),(0,s.jsx)("div",{className:"text-xs text-[var(--colorTextSecondary)]",children:"直接选择整个项目文件夹,系统会自动识别招标正文、清单、图纸、补疑等资料类型。"})]}),(0,s.jsx)(u.A,{color:"blue",className:"border-0",children:"按项目资料包"})]}),eE?(0,s.jsxs)("div",{className:"text-center py-8",children:[(0,s.jsx)(j.A,{}),(0,s.jsx)("div",{className:"mt-3 text-[var(--colorTextSecondary)] text-xs",children:"正在加载知识库文件…"})]}):0===eM.length?(0,s.jsx)(h.A,{image:h.A.PRESENTED_IMAGE_SIMPLE,description:"暂无知识库文件"}):(0,s.jsx)(d.A.Item,{name:"projectMaterialRoots",rules:[{required:!0,message:"请选择项目资料包"}],children:(0,s.jsx)(S.A,{treeData:eM,loadData:t8,fieldNames:{label:"rawTitle",value:"value",children:"children"},onChange:e=>{var t;return t=e.map(e=>String(e)),void ej.setFieldValue("projectMaterialRoots",ed(t))},treeCheckable:!0,showCheckedStrategy:S.A.SHOW_PARENT,placeholder:"点击这里选择项目文件夹...",style:{width:"100%"},listHeight:360,showSearch:!0,maxTagCount:"responsive",size:"large"})})]})]})})]})}}},e=>{e.O(0,[717,883,665,44,563,7,787,195,455,506,65,636,593,792],()=>e(e.s=16403)),_N_E=e.O()}]);
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[298],{16403:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/documents",function(){return r(81865)}])},81865:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>ev});var s=r(65321),l=r(97109),a=r(26171),n=r(7576),o=r(35292),i=r(33442),c=r(17807),d=r(63455),u=r(11702),p=r(88762),m=r(85114),x=r(58569),h=r(84253),g=r(34052),v=r(68787),f=r(55122),j=r(42700),y=r(2256),w=r(38770),b=r(38332),A=r(76506),k=r(50883),S=r(23718),C=r(23216),N=r(26619),I=r(8263),T=r(16285),R=r(8579),M=r(7851),z=r(29071),E=r(75548),F=r(63552),_=r(26631),B=r(7225),D=r(83914),P=r(84742),L=r(58209),W=r(38762),G=r(8470),H=r(92783),O=r(54746),q=r(93051),U=r(82930),K=r(64068),V=r(64629),Q=r(1310),X=r(67547),J=r(76830),Y=r(6578),Z=r(48321);let $={"fact-landing-round":"未覆盖重要事实落地","table-repair-round":"表格缺失或格式错误","semantic-choice-conflict":"语义矛盾数值冲突","deterministic-stage5":"确定性缺陷(来源罗列/内部术语/编造日期)","formal-source-clean":"资料来源罗列话术","qingtian-full-review":"全维度评审缺陷","planned-section-final":"规划小节内容缺失","commercial-strip":"商务数据泄漏","table-deterministic-repair":"表格数据不一致","post-review-surface":"评审后兜底缺陷","terminology-strip":"内部术语泄漏","toc-consistency":"目录与正文不一致"},{TextArea:ee}=n.A,{Text:et}=o.A,er=a.A;function es(e){let{type:t="info",title:r,children:l,style:a}=e,n="error"===t?"var(--colorError)":"warning"===t?"var(--colorWarning)":"success"===t?"var(--colorSuccess)":"var(--colorInfo)";return(0,s.jsxs)("div",{style:{border:"1px solid ".concat(n),background:"error"===t?"var(--colorErrorBg)":"warning"===t?"var(--colorWarningBg)":"success"===t?"var(--colorSuccessBg)":"var(--colorInfoBg)",borderRadius:8,padding:"9px 12px",...a},children:[(0,s.jsx)(et,{strong:!0,style:{color:n},children:r}),l&&(0,s.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12},children:l})]})}function el(e){let{children:t,gap:r=12,style:l}=e;return(0,s.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:r,...l},children:t})}let ea=null,en=!1;function eo(){null==ea||ea.listeners.forEach(e=>e())}let ei={role_binding:(0,s.jsx)(C.A,{}),knowledge_retrieval:(0,s.jsx)(N.A,{}),file_understanding:(0,s.jsx)(I.A,{}),fact_extraction:(0,s.jsx)(T.A,{}),chapter_generation:(0,s.jsx)(R.A,{}),validation:(0,s.jsx)(M.A,{}),llm_review:(0,s.jsx)(z.A,{}),reference:(0,s.jsx)(E.A,{})},ec={施工组织设计:(0,s.jsx)(M.A,{}),投标文件:(0,s.jsx)(F.A,{}),技术方案:(0,s.jsx)(T.A,{}),报告:(0,s.jsx)(_.A,{}),自定义:(0,s.jsx)(R.A,{})};function ed(e){return[...new Set(e.map(e=>e.trim()).filter(Boolean))]}function eu(e){return e.map(e=>({key:e.key,value:e.key,rawTitle:e.title,title:e.isFolder?(0,s.jsxs)("div",{className:"flex items-center justify-between w-full pr-4",children:[(0,s.jsxs)(i.A,{size:4,children:[(0,s.jsx)(B.A,{style:{color:"#faad14"}}),(0,s.jsx)("span",{children:e.title})]}),(0,s.jsxs)("span",{className:"text-xs text-[var(--colorTextTertiary)]",children:[e.fileCount||0," 项"]})]}):(0,s.jsx)("span",{title:e.key,children:e.title}),isFolder:e.isFolder,fileCount:e.fileCount||+!e.isFolder,isLeaf:e.isLeaf}))}let ep={role_binding:"角色配置绑定",knowledge_retrieval:"知识库检索",file_understanding:"多模态文件理解",fact_extraction:"LLM 事实抽取",chapter_generation:"LLM 章节生成",validation:"规则校验",llm_review:"LLM 审查优化",reference:"参考资源处理"},em={"knowledge-base":"知识库","document-readiness":"生成准备度检查"},ex={wait:"common.statusWaiting",process:"common.statusRunning",finish:"common.statusCompleted",warning:"common.statusReview",error:"common.statusAbnormal"},eh={running:"common.statusRunning",success:"common.statusCompleted",skipped:"common.statusSkipped",failed:"common.statusFailed"},eg={error:"common.levelError",warning:"common.levelWarning",info:"common.levelInfo"};function ev(){var e,t,r,a,o,E,F,B;let ev=(0,Z.Vr)(),{message:ef}=c.A.useApp(),[ej]=d.A.useForm(),ey=(0,l.useRef)(null),[ew,eb]=(0,l.useState)([]),[eA,ek]=(0,l.useState)("construction-organization-design"),[eS,eC]=(0,l.useState)([]),[eN,eI]=(0,l.useState)([]),[eT,eR]=(0,l.useState)([]),[eM,ez]=(0,l.useState)([]),[eE,eF]=(0,l.useState)(!1),[e_,eB]=(0,l.useState)(!0),[eD,eP]=(0,l.useState)(!1),[eL,eW]=(0,l.useState)(null),[eG,eH]=(0,l.useState)(""),[eO,eq]=(0,l.useState)([]),[eU,eK]=(0,l.useState)(null),[eV,eQ]=(0,l.useState)(null),[eX,eJ]=(0,l.useState)(""),[eY,eZ]=(0,l.useState)(!1),[e$,e0]=(0,l.useState)("idle"),[e1,e2]=(0,l.useState)(null),[e6,e5]=(0,l.useState)(null),[e8,e3]=(0,l.useState)({start:0,end:0}),[e4,e7]=(0,l.useState)([]),[e9,te]=(0,l.useState)(!1),[tt,tr]=(0,l.useState)(!1),[ts,tl]=(0,l.useState)({}),[ta,tn]=(0,l.useState)(null),to=(0,l.useRef)({}),ti=(0,l.useRef)(new Map),[tc,td]=(0,l.useState)(0),[tu,tp]=(0,l.useState)([]),tm=(0,l.useMemo)(()=>{var e,t,r;return(null==(e=eT.find(e=>e.selected))?void 0:e.projectRoot)||(null==(t=eT.find(e=>e.isCurrent))?void 0:t.projectRoot)||(null==(r=eT[0])?void 0:r.projectRoot)||""},[eT]),[tx,th]=(0,l.useState)([]),[tg,tv]=(0,l.useState)(null),[tf,tj]=(0,l.useState)(null),[ty,tw]=(0,l.useState)("templates"),[tb,tA]=(0,l.useState)(!1),[tk,tS]=(0,l.useState)("workflow"),[tC,tN]=(0,l.useState)(new Set),[tI,tT]=(0,l.useState)(!1),[tR,tM]=(0,l.useState)(!1),[tz,tE]=(0,l.useState)(null),tF=(0,l.useRef)(new Map),t_=(0,l.useRef)(""),tB=(0,l.useRef)(null),tD=(0,l.useRef)(0),tP=(0,l.useMemo)(()=>"activeGenDocId:".concat(tm||"default"),[tm]),tL=async()=>{try{eq((await (0,Y.cQ)(tm||void 0)).documents)}catch(e){eq([])}};(0,l.useEffect)(()=>{let e=()=>{ea&&(th(ea.flowSteps),tv(ea.activeFlowKey),eP(ea.loading),ea.documentId&&eK(ea.documentId),ea.draft&&eW(ea.draft),void 0!==ea.content&&eH(ea.content))},t=ea;return null==t||t.listeners.add(e),e(),()=>{null==t||t.listeners.delete(e)}},[]),(0,l.useEffect)(()=>{eB(!0),Promise.all([(0,Y.Dl)().then(e=>{var t,r;eb(e.templates),ek(null!=(r=null==(t=e.templates[0])?void 0:t.id)?r:"construction-organization-design")}),(0,Y.lv)().then(e=>{eC(e.roles),eI(e.configs)}),(0,Y.dx)().then(e=>eR(e))]).catch(()=>ef.error(ev("common.error"))).finally(()=>eB(!1))},[ef,ev]),(0,l.useEffect)(()=>{if(0===ew.length||!tm)return;let e=!1;return(async()=>{let t=await Promise.all(ew.map(async e=>{try{let{validation:t}=await (0,Y.SM)(e.id,tm);return[e.id,t]}catch(e){return null}}));if(e)return;let r={};for(let e of t)e&&(r[e[0]]=e[1]);tl(r)})(),()=>{e=!0}},[ew,tm]),(0,l.useEffect)(()=>{tm&&(localStorage.removeItem("activeGenDocId"),tL())},[tm]),(0,l.useEffect)(()=>{if(0===eO.length)return;let e=localStorage.getItem(tP);if(!e)return;if(!eO.find(t=>t.id===e&&"generating"===t.status))return void localStorage.removeItem(tP);let t=setInterval(()=>{(async()=>{try{let{document:r}=await (0,Y.v7)(e,!1,tm||void 0);if(!r)return;await tL(),"generating"!==r.status&&(localStorage.removeItem(tP),clearInterval(t))}catch(e){clearInterval(t)}})()},3e3);return()=>clearInterval(t)},[eO]);let tW=(0,l.useMemo)(()=>ew.find(e=>e.id===eA),[ew,eA]),tG=eN.map(e=>({label:e.name,value:e.id})),tH=Math.max(0,tx.findIndex(e=>e.key===tg)),tO=e=>{var t;return e?(null==(t=eS.find(t=>t.id===e))?void 0:t.name)||em[e]||"未知角色":""},tq=e=>e.subtitle||e.roleName||tO(e.roleId)||ep[e.type]||e.type,tU=e=>{var t,r,s;return e.promptName||((t=e.promptId)?(null==(r=eT.find(e=>e.id===t))?void 0:r.projectName)||(null==(s=eS.find(e=>e.id===t))?void 0:s.name)||em[t]||"未知提示词":"")},tK=()=>{tD.current+=1,eJ(""),e2(null),e5(null),e7([]),te(!1),eZ(!1),e0("idle")},tV=async e=>{eK(e.id),ek(e.templateId);let t=tQ(e.status);if(t||"failed"===e.status||"aborted"===e.status){tK(),tj(e),eW(null),eH(""),eP(t),tS("workflow"),tA(!0);try{let{document:t}=await (0,Y.v7)(e.id,!1,e.projectRoot||tm||void 0);if(!t)throw Error("文档记录不存在");tZ(t),tQ(t.status)?t2(t.id,t.projectRoot||e.projectRoot||tm||void 0):await tL()}catch(t){tZ(e)}return}tS("editor"),th([]),tv(null),tK();try{let{document:t}=await (0,Y.v7)(e.id,!1,e.projectRoot||tm||void 0);if(!t)throw Error("文档记录不存在");eW(t.draft||null),eH(t.editedMarkdown||t.markdown),tp(t.exportReports||[])}catch(e){ef.error(ev("common.error"))}tA(!0)},tQ=e=>"completed"!==e&&"completed_with_issues"!==e&&"warning"!==e&&"failed"!==e&&"aborted"!==e,tX=e=>{var t,r,s,l,a,n;return!!e&&("failed"===e.status||"aborted"===e.status||"completed_with_issues"===e.status||"warning"===e.status&&!!(null==(t=e.checkpointChapters)?void 0:t.length)&&/继续生成|重新生成|中断|卡住|未完成|门禁|阻断/u.test(e.error||(null==(r=e.warningIssues)?void 0:r.join(";"))||(null==(a=e.draft)||null==(l=a.exportGate)||null==(s=l.blockingIssues)?void 0:s.map(e=>e.message).join(";"))||"")||!!((null==(n=e.draft)?void 0:n.exportGate)&&!1===e.draft.exportGate.passed))},tJ=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:eD;(null==ea?void 0:ea.loading)&&(ea.flowSteps=e,ea.activeFlowKey=t,ea.loading=r,eo())},tY=e=>{var t,r,l,a;let n=e.executionStages||(null==(t=e.draft)?void 0:t.executionStages)||[];if(n.length>0){let t=n.map((t,r)=>{var l;let a,n=("failed"===e.status||"aborted"===e.status)&&"running"===t.status||"failed"===(a=t.status)?"error":"running"===a?"process":"finish";return{key:"".concat(t.type,"-").concat(r),title:t.title||ep[t.type]||t.type,subtitle:tq(t),description:t.message||"",status:n,icon:"role_binding"===(l=t.type)?(0,s.jsx)(C.A,{}):"knowledge_retrieval"===l?(0,s.jsx)(N.A,{}):"file_understanding"===l?(0,s.jsx)(I.A,{}):"fact_extraction"===l?(0,s.jsx)(T.A,{}):"chapter_generation"===l?(0,s.jsx)(R.A,{}):"llm_review"===l?(0,s.jsx)(z.A,{}):"validation"===l?(0,s.jsx)(M.A,{}):(0,s.jsx)(_.A,{}),subSteps:((e,t,r)=>{let s=Array.isArray(e.details)?e.details.filter(Boolean):[],l=e.progress?"".concat(e.progress.label||"进度",":").concat(e.progress.current,"/").concat(e.progress.total):"",a=[...l?[l]:[],...s];return 0===a.length?[{key:"stage-".concat(r),title:tU(e)?"提示词:".concat(tU(e)):tq(e),status:t}]:a.map((e,s)=>({key:"stage-".concat(r,"-").concat(s),title:e,status:"process"===t&&0===s?"process":"error"===t&&0===s?"error":"warning"===t?"warning":"process"===t?"finish":t}))})(t,n,r)}});"generating"===e.status&&t.length>0&&t.every(e=>"process"!==e.status)&&t.push({key:"finishing-".concat(t.length),title:"生成收尾中",subtitle:"",description:"章节已全部生成,正在执行全局一致性审查与质量校验。",status:"process",icon:(0,s.jsx)(D.A,{}),subSteps:[]});let o="generating"===e.status?(null==(r=t.at(-1))?void 0:r.key)||"prepare":"failed"===e.status||"aborted"===e.status?(null==(l=t.find(e=>"error"===e.status))?void 0:l.key)||(null==(a=t.at(-1))?void 0:a.key)||"prepare":"done";return{steps:t,activeKey:o}}return{steps:[],activeKey:null}},tZ=e=>{let t=e.executionStages||[],r="".concat(e.id,"|").concat(e.updatedAt,"|").concat(e.status,"|").concat(e.error||"","|").concat(t.length,"|").concat(t.map(e=>{var t,r,s,l;return"".concat(e.status,":").concat(null!=(s=null==(t=e.progress)?void 0:t.current)?s:0,"/").concat(null!=(l=null==(r=e.progress)?void 0:r.total)?l:0)}).join(","));if(t_.current===r)return;t_.current=r,tj(e);let{steps:s,activeKey:l}=tY(e);t$(s),th(s),tv(l),eP(tQ(e.status)),tJ(s,l,tQ(e.status)),("failed"===e.status||"aborted"===e.status)&&tS("workflow"),("completed"===e.status||"completed_with_issues"===e.status||"warning"===e.status)&&e.draft&&(eW(e.draft),eH(e.editedMarkdown||e.markdown),tS("editor"),th([]),tv(null),tp(e.exportReports||[]))},t$=e=>{let t=Date.now();for(let r of e){let e=ti.current.get(r.key);"process"!==r.status||e?("finish"===r.status||"error"===r.status||"warning"===r.status)&&e&&!e.endedAt&&ti.current.set(r.key,{...e,endedAt:t}):ti.current.set(r.key,{startedAt:t})}},t0=e=>{let t=Math.max(0,Math.round(e/1e3));if(t<60)return"".concat(t," 秒");let r=Math.floor(t/60);return r<60?"".concat(r," 分 ").concat(t%60," 秒"):"".concat(Math.floor(r/60)," 小时 ").concat(r%60," 分")},t1=e=>{let t=tF.current.get(e);t&&(clearInterval(t),tF.current.delete(e))},t2=(e,t)=>{t1(e);let r=setInterval(()=>{(async()=>{try{let{document:r}=await (0,Y.v7)(e,!0,t||tm||void 0);if(!r)return;tZ(r),await tL(),tQ(r.status)||(t1(e),localStorage.removeItem(tP))}catch(e){}})()},2e3);tF.current.set(e,r)};(0,l.useEffect)(()=>()=>{for(let e of tF.current.values())clearInterval(e);tF.current.clear(),tB.current&&(clearTimeout(tB.current),tB.current=null)},[]),(0,l.useEffect)(()=>{if(!eD||!tg)return;let e=window.setInterval(()=>th(e=>{let t=e.map(e=>{if(e.key!==tg||"process"!==e.status)return e;let t=e.subSteps.findIndex(e=>"process"===e.status),r=t<0?0:Math.min(t+1,e.subSteps.length-1);return{...e,subSteps:e.subSteps.map((e,t)=>t<r?{...e,status:"finish"}:t===r?{...e,status:"process"}:{...e,status:"wait"})}});return tJ(t,tg),t}),1400);return()=>window.clearInterval(e)},[tg,eD]),(0,l.useEffect)(()=>{if(!eD)return;let e=window.setInterval(()=>td(e=>e+1),1e3);return()=>window.clearInterval(e)},[eD]);let t6=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";eF(!0);try{let t=await (0,Y.Fi)(e,tm||void 0);ez(eu(t.nodes))}catch(e){ef.error("知识库文件加载失败")}finally{eF(!1)}},t5=async e=>{var t;let r=String(null!=(t=e.key)?t:"");if(r)try{let e=await (0,Y.Fi)(r,tm||void 0),t=eu(e.nodes),s=e=>e.map(e=>e.key===r?{...e,children:t}:e.children?{...e,children:s(e.children)}:e);ez(e=>s(e))}catch(e){ef.error("加载子文件夹失败")}},t8=e=>{let t=null!=e?e:{id:"tpl-".concat(Date.now()),name:"",description:"",category:"自定义",outputTitle:"",projectRoleConfigId:void 0,chapters:[],projectBindings:[]};ej.resetFields(),ej.setFieldsValue({...t,projectMaterialRoots:ed((t.projectBindings||[]).map(e=>e.materialRootPath).filter(Boolean))}),t6(),tr(!0)},t3=async()=>{try{await ej.validateFields();let e=ej.getFieldsValue(!0),t=ed(e.projectMaterialRoots||[]).map(e=>({materialRootPath:e})),{projectMaterialRoots:r,...s}=e,l={...s,chapters:[],projectBindings:t},a=await (0,Y.l2)(l);eb(a.templates),ek(a.template.id),tr(!1),await tL(),ef.success(ev("common.success"))}catch(e){e instanceof Error&&ef.error(e.message)}},t4=async e=>{try{let t=await (0,Y.bV)(e);eb(t.templates),ek(t.template.id),ef.success(ev("common.success"))}catch(e){ef.error(ev("common.error"))}},t7=async e=>{try{var t,r;let s=await (0,Y.h0)(e);eb(s.templates),ek(null!=(r=null==(t=s.templates[0])?void 0:t.id)?r:""),ef.success(ev("common.success"))}catch(e){ef.error(ev("common.error"))}},t9=async e=>{tE(e),ek(e),eK(null),eW(null),eH(""),tK(),tS("workflow"),tA(!0),tw("drafts"),eP(!0),tv("prepare"),th([{key:"prepare",title:"正在准备运行模板",description:"正在校验模板绑定的项目资料包、提示词配置和资料索引,校验通过后会自动开始生成。",status:"process",icon:(0,s.jsx)(D.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"process"},{key:"start",title:"准备生成任务",status:"wait"}]}]);try{let{validation:t}=await (0,Y.SM)(e,tm||void 0);tl(r=>({...r,[e]:t}));let r=t.issues.filter(e=>"error"===e.level);if(r.length>0){rs.current=!0,eP(!1),tv("prepare"),th([{key:"prepare",title:"模板运行前检查未通过",description:r.map(e=>e.message).join("\n"),status:"error",icon:(0,s.jsx)(W.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"error"},{key:"start",title:"准备生成任务",status:"wait"}]}]),ef.warning("模板运行前检查未通过,请先处理阻断项");return}t.issues.length>0&&ef.warning("模板存在非阻断警告,已继续运行"),th([{key:"prepare",title:"模板检查通过,正在创建生成任务",description:"已确认模板绑定资源可用,正在启动后台生成任务。",status:"process",icon:(0,s.jsx)(D.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"finish"},{key:"start",title:"准备生成任务",status:"process"}]}]),await rr(e)}catch(t){rs.current=!0;let e=t instanceof Error?t.message:"模板运行前检查失败";eP(!1),th([{key:"prepare",title:"模板运行准备失败",description:e,status:"error",icon:(0,s.jsx)(W.A,{}),subSteps:[{key:"validate",title:"模板运行前检查",status:"error"},{key:"start",title:"准备生成任务",status:"wait"}]}]),ef.error(e)}finally{tE(t=>t===e?null:t)}},re=async e=>{try{await (0,Y.QG)(e.id,e.projectRoot||tm||void 0),eU===e.id&&(eK(null),eW(null),eH("")),await tL(),ef.success(ev("common.success"))}catch(e){ef.error(ev("common.error"))}},rt=async(e,t)=>{let r=Date.now(),s=0,l=Date.now(),a=0;for(;;){let n;if(null==t?void 0:t.aborted)throw Error("用户中止");let o=new AbortController;t&&(t.pollController=o);try{({document:n}=await (0,Y.v7)(e,!0,tm||void 0,o.signal,s||void 0)),a=0}catch(e){if((null==t?void 0:t.aborted)||e instanceof DOMException&&"AbortError"===e.name)throw Error("用户中止",{cause:e});if((a+=1)>=3)throw e instanceof Error?e:Error("生成进度获取失败");await new Promise(e=>window.setTimeout(e,2e3*a));continue}finally{(null==t?void 0:t.pollController)===o&&(t.pollController=void 0)}if(!n){if(Date.now()-r>75e5||Date.now()-l>96e4)throw Error("生成任务疑似卡住,请点击继续生成或重新生成(后台任务可能仍在运行,稍后刷新可查看)");await new Promise(e=>window.setTimeout(e,1500));continue}if(tZ(n),n.updatedAt!==s&&(s=n.updatedAt,l=Date.now()),("completed"===n.status||"completed_with_issues"===n.status||"warning"===n.status)&&n.draft)return n;if("warning"===n.status&&n.error&&/已中断/u.test(n.error))throw Error(n.error);if("failed"===n.status||"aborted"===n.status)throw Error(n.error||("aborted"===n.status?"生成已中止":"生成失败"));if(Date.now()-r>75e5||Date.now()-l>96e4)throw Error("生成任务疑似卡住,请点击继续生成或重新生成(后台任务可能仍在运行,稍后刷新可查看)");await new Promise(e=>window.setTimeout(e,1500))}},rr=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eA;if(!e)return;if((null==ea?void 0:ea.aborted)&&(ea=null),null==ea?void 0:ea.loading){th(ea.flowSteps),tv(ea.activeFlowKey),eP(!0);return}if(!tm)return void ef.error("未识别当前项目,请先选择或打开项目后再生成文件");eP(!0);let t=tx.length>0?tx:[{key:"prepare",title:"正在创建生成任务",description:"系统正在创建后台生成任务,请稍候。",status:"process",icon:(0,s.jsx)(D.A,{}),subSteps:[{key:"start",title:"准备生成任务",status:"process"}]}],r=tg||"prepare";th(t),tv(r);let l=(0,Y.OX)({templateId:e,projectRoot:tm});ea={id:Date.now(),templateId:e,loading:!0,flowSteps:t,activeFlowKey:r,promise:l,listeners:new Set};let a=[];try{let e=await l;e.documentId&&(localStorage.setItem(tP,e.documentId),eK(e.documentId),(null==ea?void 0:ea.promise)===l&&(ea.documentId=e.documentId)),await tL();let t=e.documentId?await rt(e.documentId,(null==ea?void 0:ea.promise)===l?ea:void 0):void 0,r=e.draft||(null==t?void 0:t.draft);if(!r)throw Error("生成结果为空");(e.documentId||(null==t?void 0:t.id))&&eK(e.documentId||t.id),a.forEach(e=>window.clearTimeout(e)),eW(r),eH((null==t?void 0:t.editedMarkdown)||(null==t?void 0:t.markdown)||r.markdown),(null==ea?void 0:ea.promise)===l&&(ea.draft=r,ea.content=(null==t?void 0:t.editedMarkdown)||(null==t?void 0:t.markdown)||r.markdown);let s=t||{id:e.documentId||"draft-".concat(Date.now()),templateId:eA,title:r.title,requirement:r.requirement,projectRoot:r.projectRoot||tm,projectId:r.projectId,markdown:r.markdown,status:r.validationIssues.some(e=>"error"===e.level||"warning"===e.level)||!r.exportGate.passed?"warning":"completed",draft:r,executionStages:r.executionStages,assets:r.assets||[],createdAt:r.generatedAt,updatedAt:Date.now()},{steps:n}=tY(s);th(n),tJ(n,"done",!1),tv("done"),(null==ea?void 0:ea.promise)===l&&(ea.activeFlowKey="done",ea.loading=!1,eo(),ea=null),localStorage.removeItem(tP),await tL(),ef.success(ev("common.success")),window.setTimeout(()=>{var e;return null==(e=ey.current)?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},200)}catch(s){localStorage.removeItem(tP);let e=s instanceof Error?s.message:ev("common.error"),t=en;en=!1;let r=!t&&"用户中止"===e;t||th(t=>{let r=t.map(t=>"process"===t.status?{...t,status:"error",description:e,subSteps:((e,t)=>{if("wait"===t)return e.subSteps.map(e=>({...e,status:"wait"}));if("finish"===t)return e.subSteps.map(e=>({...e,status:"finish"}));if("error"===t)return e.subSteps.map((e,t)=>({...e,status:0===t?"error":e.status}));let r=e.subSteps.findIndex(e=>"wait"===e.status);return e.subSteps.map((e,t)=>t<r||-1===r?{...e,status:"finish"}:t===r?{...e,status:"process"}:e)})(t,"error")}:t);return tJ(r,tg,!1),r}),(null==ea?void 0:ea.promise)===l&&(ea.loading=!1,ea.error=e,eo(),ea=null),await tL().catch(()=>void 0),r?ef.warning("生成任务已被中止(可能来自其他窗口):可在列表中点击「继续生成」恢复"):t||ef.error(e)}finally{a.forEach(e=>window.clearTimeout(e)),eP(!1),en=!1,(null==ea?void 0:ea.promise)===l&&(ea.loading=!1,eo())}},rs=(0,l.useRef)(!1);(0,l.useEffect)(()=>(tB.current&&(clearTimeout(tB.current),tB.current=null),!tb||"workflow"!==tk||tz||eU||rs.current||(null==ea?void 0:ea.loading)||null==tW||!tW.projectRoleConfigId||(rs.current=!0,tB.current=setTimeout(()=>{tB.current=null,tb&&"workflow"===tk&&!eU&&eA==eA&&rr()},300)),tb||(rs.current=!1),()=>{tB.current&&(clearTimeout(tB.current),tB.current=null)}),[tb,tk,tz,eU,tW,eA]);let rl=async e=>{try{eK(e.id),ek(e.templateId),tS("workflow"),tA(!0),eP(!0);let t=await (0,Y.UQ)(e.id,e.projectRoot||tm||void 0);localStorage.setItem(tP,t.documentId),await tL();let r=await rt(t.documentId);r.draft&&(eW(r.draft),eH(r.editedMarkdown||r.markdown||r.draft.markdown),tS("editor")),localStorage.removeItem(tP),await tL(),ef.success("已继续生成并完成")}catch(e){ef.error(e instanceof Error?e.message:"继续生成失败")}finally{eP(!1)}},ra=async e=>{if((null==ea?void 0:ea.loading)&&ea.documentId===e.id){var t;en=!0,ea.aborted=!0,null==(t=ea.pollController)||t.abort(),ea.loading=!1,ea.error="用户中止",eo(),ea=null,eP(!1)}localStorage.removeItem(tP),t1(e.id);try{await (0,Y.r)(e.id,e.projectRoot||tm||void 0),ef.success("已中止生成任务")}catch(e){ef.info("任务已不在运行,已刷新状态")}finally{await tL(),eU===e.id&&(eK(null),tj(null),eW(null),eH(""))}},rn=(e,t,r)=>{let s=new Blob([e],{type:r}),l=URL.createObjectURL(s),a=document.createElement("a");a.href=l,a.download=t,a.target="_self",a.rel="noopener",a.style.display="none",document.body.appendChild(a),a.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window})),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(l),1e3)},ro=async e=>{if(eL){eQ(e);try{let t={documentId:eU||void 0,title:eL.title,markdown:eG,format:e,enforceGate:!1,exportGate:eL.exportGate,useClientMarkdown:!0,projectRoot:eL.projectRoot||tm||void 0},r=await (0,Y.UE)(t);if(rn(r,"".concat(eL.title,".").concat("markdown"===e?"md":e),{markdown:"text/markdown;charset=utf-8",html:"text/html;charset=utf-8",pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}[e]),eU)try{let{document:e}=await (0,Y.v7)(eU,!1,eL.projectRoot||tm||void 0);e&&tp(e.exportReports||[])}catch(e){}}catch(e){ef.error(e instanceof Error?e.message:ev("common.error"))}finally{eQ(null)}}},ri=()=>{var e;return!!((null==tf?void 0:tf.editedMarkdown)||(null==tf?void 0:tf.markdown)||(null==tf||null==(e=tf.draft)?void 0:e.markdown)||"").trim()},rc=async e=>{var t;if(!tf)return;let r=tf.editedMarkdown||tf.markdown||(null==(t=tf.draft)?void 0:t.markdown)||"";if(!r.trim())return void ef.warning("该记录暂无可导出的正文内容");eQ(e);try{let t="markdown"===e?"md":e,s=await (0,Y.UE)({documentId:tf.id,title:tf.title,markdown:r,format:e,enforceGate:!1,useClientMarkdown:!0,projectRoot:tf.projectRoot||tm||void 0});rn(s,"".concat(tf.title,".").concat(t),{markdown:"text/markdown;charset=utf-8",html:"text/html;charset=utf-8",pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}[e])}catch(e){ef.error(e instanceof Error?e.message:ev("common.error"))}finally{eQ(null)}},rd=async()=>{if(eL)try{if(eU)await (0,Y.a6)(eU,{editedMarkdown:eG,markdown:eG},eL.projectRoot||tm||void 0);else{let e=await (0,Y.Af)({...eL,markdown:eG});eW(e.draft)}await tL(),ef.success(ev("common.success"))}catch(e){ef.error(ev("common.error"))}},ru=(e,t)=>{e7(r=>[{id:"".concat(Date.now()),content:e,prompt:t,createdAt:Date.now()},...r].slice(0,12))},rp=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e&&eJ(""),e2(null),e5(null),e3({start:0,end:0})},rm=(e,t)=>{var r,s;return{title:(null==eL?void 0:eL.title)||"未命名文档",markdown:t,instruction:e,facts:null==eL||null==(r=eL.structuredFacts)?void 0:r.map(e=>"".concat(e.key,": ").concat(e.value)),chapters:null==eL||null==(s=eL.chapters)?void 0:s.map(e=>e.title),...(()=>{let e=e8.start,t=e8.end;return t>e?{selection:{start:e,end:t,text:eG.slice(e,t)},cursorOffset:e}:{cursorOffset:e}})()}},rx=async()=>{let e=eX.trim();if(!eL||!e||eY)return;let t=tD.current+1;tD.current=t,eZ(!0),e0("planning"),e5(null);try{let r=await (0,Y.Gi)({mode:"plan",...rm(e,eG)});if(tD.current!==t||eU!=eU)return;if(!r.plan)throw Error("AI 未返回修改计划");e2(r.plan)}catch(e){tD.current===t&&ef.error(e instanceof Error?e.message:ev("common.error"))}finally{tD.current===t&&(eZ(!1),e0("idle"))}},rh=async e=>{let t=eX.trim();if(!eL||!t||eY)return;let r=tD.current+1;tD.current=r,eZ(!0),e0("applying");try{let s=await (0,Y.Gi)({mode:"apply",...rm(t,eG),plan:e});if(tD.current!==r||eU!=eU)return;if(!s.markdown)throw Error("AI 未返回修改结果");e5({plan:s.plan||e,markdown:s.markdown,beforeSnippet:s.beforeSnippet,afterSnippet:s.afterSnippet,summary:s.summary,changedChars:s.changedChars,prompt:t,before:eG})}catch(e){tD.current===r&&ef.error(e instanceof Error?e.message:ev("common.error"))}finally{tD.current===r&&(eZ(!1),e0("idle"))}};if(e_)return(0,s.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,s.jsx)(p.A,{active:!0,title:!0,paragraph:{rows:1}}),(0,s.jsx)(p.A,{active:!0,paragraph:{rows:2}}),(0,s.jsx)(p.A,{active:!0,paragraph:{rows:8}})]});let rg="workflow"===tk?"工作流:".concat((null==tW?void 0:tW.name)||"选择模板"):"编辑:".concat((null==eL?void 0:eL.title)||(null==tW?void 0:tW.outputTitle)||"文档");return(0,s.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end justify-between gap-4 pb-6 mb-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h1",{className:"text-3xl font-extrabold tracking-tight text-[var(--colorText)] mb-2.5 flex items-center gap-2",children:[(0,s.jsx)(C.A,{className:"text-[var(--colorAccent)]"}),ev("documents.title")]}),(0,s.jsx)("p",{className:"text-sm text-[var(--colorTextSecondary)]",children:ev("documents.description")})]}),(0,s.jsx)(m.Ay,{type:"primary",icon:(0,s.jsx)(O.A,{}),onClick:()=>t8(),className:"shadow-none rounded-lg",children:ev("documents.newTemplate")})]}),(0,s.jsxs)("div",{className:"bg-[var(--colorBgContainer)] rounded-2xl shadow-sm overflow-hidden",children:[(0,s.jsx)(x.A,{items:[{key:"templates",label:(0,s.jsxs)("span",{className:"px-4",children:["模板库 ",(0,s.jsx)(u.A,{className:"ml-2 border-0 bg-[var(--colorFillAlter)]",children:ew.length})]})},{key:"drafts",label:(0,s.jsxs)("span",{className:"px-4",children:["生成记录 ",(0,s.jsx)(u.A,{className:"ml-2 border-0 bg-[var(--colorFillAlter)]",children:eO.length})]})}],activeKey:ty,onChange:tw,className:"documents-tabs",size:"large",tabBarStyle:{margin:0,padding:"0 16px",background:"var(--colorBgHover)",borderBottom:"1px solid var(--borderColor)"}}),(0,s.jsx)("div",{className:"p-4 bg-[var(--colorFillAlter)] min-h-[500px]",children:"templates"===ty?0===ew.length?(0,s.jsx)("div",{className:"py-32 text-center border border-dashed border-[var(--borderColor)] rounded-2xl bg-[var(--colorBgContainer)]",children:(0,s.jsx)(h.A,{description:(0,s.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:ev("common.noData")})})}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4",children:ew.map(e=>(0,s.jsxs)("div",{ref:t=>{to.current[e.id]=t},className:"group flex items-center p-4 rounded-2xl transition-all cursor-pointer ".concat(eA===e.id?"bg-[var(--colorBgSelected)] shadow-md":"bg-[var(--colorBgContainer)] hover:bg-[var(--colorBgHover)] shadow-sm hover:shadow-md"),onClick:()=>ek(e.id),children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0 pr-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-2 min-w-0",children:[function(e,t){let r=ec[e]||(0,s.jsx)(_.A,{});return(0,s.jsx)("span",{style:{color:t?"var(--colorAccent)":"var(--colorTextSecondary)",fontSize:16,marginTop:2,flexShrink:0},children:r})}(e.category,eA===e.id),(0,s.jsx)("span",{className:"font-bold text-base text-[var(--colorText)] truncate",children:e.name}),eA===e.id&&(0,s.jsx)(u.A,{color:"blue",className:"border-0 m-0 shrink-0",children:"当前选中"}),(0,s.jsx)(u.A,{className:"border-0 bg-[var(--colorFillSecondary)] m-0 shrink-0",children:e.category})]}),e.description&&(0,s.jsx)("div",{className:"text-sm text-[var(--colorTextSecondary)] line-clamp-2 leading-relaxed mb-3",children:e.description}),(e=>{let t=ts[e.id];if(!t)return null;let r=t.issues.filter(e=>"error"===e.level),l=t.issues.filter(e=>"warning"===e.level),a=ta===e.id,n=t.roleDiagnostics||[],o=new Map;for(let e of t.promptDiagnostics){let t=o.get(e.roleId)||[];t.push(e),o.set(e.roleId,t)}let i=t.strategyPreview,c=(null==i?void 0:i.mode)==="strict"?"error":(null==i?void 0:i.mode)==="fast"?"blue":(null==i?void 0:i.mode)==="longform"?"purple":"green";return(0,s.jsxs)("div",{onClick:e=>e.stopPropagation(),className:"flex flex-col items-start gap-2 w-full",children:[(0,s.jsxs)("div",{className:"inline-flex items-center gap-2 p-1.5 px-3 rounded-lg border text-xs ".concat(r.length?"border-red-200 bg-red-50/50":l.length?"border-yellow-200 bg-yellow-50/50":"border-green-200 bg-green-50/50"),children:[(0,s.jsx)("span",{className:"font-medium",children:r.length?"检查未通过(".concat(r.length," 项阻断)"):l.length?"存在警告(".concat(l.length," 项)"):"检查通过"}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["项目资料 ",t.fileDiagnostics.length]}),(0,s.jsxs)("span",{children:["提示词 ",t.promptDiagnostics.length]}),(0,s.jsxs)("span",{children:["角色链路 ",n.length]}),i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)(u.A,{color:c,className:"border-0 m-0",children:[i.mode," 策略预估"]})]}),!r.length&&l.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsx)("span",{className:"text-blue-500 cursor-pointer hover:underline",onClick:()=>{t9(e.id)},children:"忽略警告并运行"})]}),(0,s.jsxs)("span",{className:"text-blue-500 cursor-pointer hover:underline",onClick:()=>tn(a?null:e.id),children:[a?(0,s.jsx)(G.A,{}):(0,s.jsx)(H.A,{}),a?"收起体检":"体检报告"]})]}),a&&(0,s.jsxs)("div",{className:"w-full flex flex-col gap-3 rounded-xl border border-[var(--borderColor)] bg-[var(--colorBgContainer)] p-3",children:[r.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("span",{className:"text-xs font-bold text-[var(--colorError)]",children:["阻断项(",r.length,")— 必须修复后才能运行"]}),r.map(t=>{var r;let l=(r=t.message,/资料包|项目资料|知识库|索引/u.test(r)?{label:"配置模板",onClick:()=>t8(e)}:/提示词|绑定/u.test(r)?{label:"提示词库",href:"/prompt"}:/项目角色配置/u.test(r)?{label:"角色配置",href:"/document-roles"}:void 0);return(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50/40 px-2.5 py-1.5 text-xs",children:[(0,s.jsx)("span",{className:"text-[var(--colorText)]",children:t.message}),l&&(l.href?(0,s.jsxs)("a",{className:"shrink-0 text-red-500 hover:underline",href:l.href,children:[l.label," ›"]}):(0,s.jsxs)("span",{className:"shrink-0 text-red-500 cursor-pointer hover:underline",onClick:l.onClick,children:[l.label," ›"]}))]},t.message)})]}),l.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("span",{className:"text-xs font-bold text-[var(--colorWarning)]",children:["警告项(",l.length,")— 可忽略并继续运行"]}),l.map(e=>(0,s.jsx)("div",{className:"rounded-lg border border-yellow-200 bg-yellow-50/40 px-2.5 py-1.5 text-xs text-[var(--colorTextSecondary)]",children:e.message},e.message))]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("span",{className:"text-xs font-bold text-[var(--colorText)]",children:["绑定链路(",t.configName||"未绑定角色配置",")"]}),0===n.length?(0,s.jsx)("span",{className:"text-xs text-[var(--colorTextTertiary)]",children:"未配置提示词角色链路"}):(0,s.jsx)("div",{className:"flex flex-col gap-1.5",children:n.map(r=>{let l=o.get(r.roleId)||[];return(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs flex-wrap rounded-lg border border-[var(--borderColor)] bg-[var(--colorFillQuaternary)] px-2 py-1",children:[(0,s.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:e.name}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"→"}),(0,s.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:t.configName||"角色配置"}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"→"}),(0,s.jsx)("span",{className:"ok"===r.status?"text-[var(--colorText)]":"text-[var(--colorError)] font-medium",children:r.roleName||r.roleId}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"→"}),0===l.length?(0,s.jsx)(u.A,{color:"error",className:"border-0 m-0",children:"missing_resource"===r.status?"角色未绑定资源":"role_missing"===r.status?"角色不存在":"未绑定提示词"}):(0,s.jsx)("span",{className:"flex items-center gap-1 flex-wrap",children:l.map(e=>(0,s.jsx)(u.A,{color:e.exists&&e.contentLength>0?"success":e.exists?"warning":"error",className:"border-0 m-0",title:e.contentPreview||e.promptId,children:e.exists?"".concat(e.promptTitle||e.promptId," ").concat(e.contentLength,"字符"):"".concat(e.promptId," 已删除")},e.promptId))})]},r.roleId)})})]}),i&&(0,s.jsxs)("div",{className:"flex flex-col gap-1 rounded-lg border border-blue-200 bg-blue-50/40 px-2.5 py-2 text-xs",children:[(0,s.jsx)("span",{className:"font-bold text-[var(--colorText)]",children:"生成策略预估(生成前体检)"}),(0,s.jsxs)("span",{className:"text-[var(--colorTextSecondary)]",children:["约 ",i.chapterCount," 章 / 目标 ",i.targetWords>=1e4?"".concat((i.targetWords/1e4).toFixed(1)," 万字"):"".concat(i.targetWords," 字"),";全章节并行(",i.chapterConcurrency," 章同批);审查流水线 ",i.reviewConcurrency," 路;每章证据预算 ",Math.round(i.evidenceFloorChars/1e3),"k-",Math.round(i.evidenceCeilingChars/1e3),"k 字符;修复轮次预算 ",i.repairRoundBudget," 轮",i.globalReviewSamplingRate<1?";全局审查抽检 ".concat(Math.round(100*i.globalReviewSamplingRate),"%"):""]}),i.triggers.map(e=>(0,s.jsxs)("span",{className:"text-[var(--colorTextTertiary)]",children:["\xb7 ",e]},e))]})]})]})})(e)]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-nowrap items-center gap-2 whitespace-nowrap transition-opacity ".concat(eA===e.id?"opacity-100":"opacity-0 group-hover:opacity-100"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(m.Ay,{size:"small",onClick:t=>{t.stopPropagation(),t8(e)},className:"rounded-md",children:"配置"}),(0,s.jsx)(m.Ay,{size:"small",icon:(0,s.jsx)(q.A,{}),onClick:t=>{t.stopPropagation(),t4(e.id)},className:"rounded-md"}),(0,s.jsx)(er,{title:ev("documents.deleteTemplateConfirm"),onConfirm:t=>{null==t||t.stopPropagation(),t7(e.id)},children:(0,s.jsx)(m.Ay,{size:"small",danger:!0,icon:(0,s.jsx)(L.A,{}),onClick:e=>e.stopPropagation(),className:"rounded-md"})}),(()=>{var t;let r=ts[e.id],l=null!=(t=null==r?void 0:r.issues.filter(e=>"error"===e.level).length)?t:0;return l>0?(0,s.jsxs)(m.Ay,{size:"small",danger:!0,icon:(0,s.jsx)(U.A,{}),disabled:!!tz&&tz!==e.id,onClick:t=>{var r;t.stopPropagation(),ek(r=e.id),tn(r),window.setTimeout(()=>{var e;return null==(e=to.current[r])?void 0:e.scrollIntoView({behavior:"smooth",block:"center"})},50)},className:"min-w-[108px] rounded-md justify-center",children:["先修复 ",l," 个问题"]}):(0,s.jsx)(m.Ay,{size:"small",type:"primary",icon:tz===e.id?(0,s.jsx)(D.A,{}):(0,s.jsx)(K.A,{}),loading:tz===e.id,disabled:!!tz&&tz!==e.id,onClick:t=>{t.stopPropagation(),t9(e.id)},className:"min-w-[72px] rounded-md justify-center",children:tz===e.id?"准备中":"运行"})})()]})]},e.id))}):0===eO.length?(0,s.jsx)("div",{className:"py-32 text-center border border-dashed border-[var(--borderColor)] rounded-2xl bg-[var(--colorBgContainer)]",children:(0,s.jsx)(h.A,{description:(0,s.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:ev("common.noData")})})}):(0,s.jsx)("div",{className:"grid grid-cols-1 gap-4",children:eO.slice(0,15).map((e,t)=>{var r,l,a,n,o,i,c,d,p,x;let h,g;return(0,s.jsxs)("div",{className:"group flex items-center gap-4 p-4 rounded-2xl transition-all cursor-pointer ".concat(eU===e.id?"bg-[var(--colorBgSelected)] shadow-md":"bg-[var(--colorBgContainer)] hover:bg-[var(--colorBgHover)] shadow-sm hover:shadow-md"),onClick:()=>{tV(e)},children:[(0,s.jsx)("div",{className:"mt-1",children:"completed"===e.status?(0,s.jsx)(P.A,{className:"text-xl text-[var(--colorOk)]"}):"failed"===e.status||"aborted"===e.status?(0,s.jsx)(W.A,{className:"text-xl text-[var(--colorDanger)]"}):"warning"===e.status||"completed_with_issues"===e.status?(0,s.jsx)(M.A,{className:"text-xl text-[var(--colorWarning)]"}):(0,s.jsx)(V.A,{spin:!0,className:"text-xl text-blue-500"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 pr-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,s.jsx)("span",{className:"font-bold text-base text-[var(--colorText)] truncate",children:e.title}),(0,s.jsxs)(u.A,{className:"border-0 bg-[var(--colorFillSecondary)] m-0 shrink-0",children:["#",t+1]}),(0,s.jsx)(u.A,{color:"completed"===(h=e.status)?"success":"completed_with_issues"===h||"warning"===h?"warning":"failed"===h?"error":"aborted"===h?"default":"processing",className:"border-0 m-0 shrink-0",children:"completed"===(g=e.status)?"已完成":"completed_with_issues"===g?"已完成(待复核)":"warning"===g?"需复核":"failed"===g?"失败":"aborted"===g?"已中止":"生成中"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-2 text-xs text-[var(--colorTextSecondary)] mb-3",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(Q.A,{})," ",new Date(e.updatedAt).toLocaleString()]}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["耗时 ",(e=>{let t=Math.max(0,Math.round(((e.completedAt||e.updatedAt)-e.createdAt)/1e3));if(t<60)return"".concat(t," 秒");let r=Math.floor(t/60),s=t%60;if(r<60)return s?"".concat(r," 分 ").concat(s," 秒"):"".concat(r," 分");let l=Math.floor(r/60),a=r%60;return a?"".concat(l," 小时 ").concat(a," 分"):"".concat(l," 小时")})(e)]}),e.partialChapters&&e.partialChapters.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["进度 ",e.partialChapters.filter(e=>"completed"===e.status).length,"/",e.partialChapters.length," 章"]}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsxs)("span",{children:["共 ",e.partialChapters.reduce((e,t)=>e+t.chars,0).toLocaleString()," 字"]})]})]}),("warning"===e.status||"failed"===e.status||"aborted"===e.status)&&(0,s.jsxs)("div",{className:"inline-flex items-center gap-2 p-1.5 px-3 rounded-lg border text-xs ".concat("failed"===e.status||"aborted"===e.status?"border-red-200 bg-red-50/50":"border-yellow-200 bg-yellow-50/50"),children:[(0,s.jsx)("span",{className:"font-medium",children:"failed"===e.status?(null==(l=e.draft)||null==(r=l.exportGate)?void 0:r.passed)===!1?"门禁未通过":"生成失败":"aborted"===e.status?"已中止":"需复核"}),(0,s.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"|"}),(0,s.jsx)("span",{className:"truncate max-w-[400px]",children:e.error||(null==(a=e.warningIssues)?void 0:a[0])||(null==(o=e.draft)||null==(n=o.validationIssues.find(e=>"error"===e.level||"warning"===e.level))?void 0:n.message)||(null==(d=e.draft)||null==(c=d.exportGate)||null==(i=c.checklist.find(e=>!e.passed))?void 0:i.label)||"需复核"})]})]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-nowrap items-center gap-2 whitespace-nowrap transition-opacity ".concat(eU===e.id?"opacity-100":"opacity-0 group-hover:opacity-100"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(m.Ay,{size:"small",type:"primary",icon:tQ(e.status)?(0,s.jsx)(V.A,{spin:!0}):(0,s.jsx)(K.A,{}),onClick:t=>{t.stopPropagation(),tV(e)},className:"min-w-[72px] rounded-md justify-center",children:"打开"}),tQ(e.status)&&(0,s.jsx)(er,{title:"确定中止此生成任务?",onConfirm:t=>{null==t||t.stopPropagation(),ra(e)},children:(0,s.jsx)(m.Ay,{size:"small",danger:!0,onClick:e=>e.stopPropagation(),className:"rounded-md",children:"中止"})}),("failed"===e.status||"aborted"===e.status||"warning"===e.status&&!!(null==(p=e.checkpointChapters)?void 0:p.length)&&/继续生成|重新生成|中断|卡住|未完成/u.test(e.error||(null==(x=e.warningIssues)?void 0:x.join(";"))||""))&&(0,s.jsx)(m.Ay,{size:"small",onClick:t=>{t.stopPropagation(),rl(e)},className:"rounded-md",children:"继续"}),(0,s.jsx)(er,{title:"确认删除?",onConfirm:t=>{null==t||t.stopPropagation(),re(e)},children:(0,s.jsx)(m.Ay,{size:"small",danger:!0,icon:(0,s.jsx)(L.A,{}),onClick:e=>e.stopPropagation(),className:"rounded-md"})})]})]},e.id)})})})]}),(0,s.jsx)(g.A,{title:rg,open:tb,onClose:()=>{for(let e of(tA(!1),tF.current.values()))clearInterval(e);tF.current.clear()},size:"large",mask:{closable:!1},style:{borderRadius:"12px 0 0 12px"},styles:{body:{padding:"16px 24px"},header:{borderRadius:"12px 0 0 0",borderBottom:"1px solid var(--colorBorderSecondary)"}},extra:eL?(0,s.jsxs)(i.A,{wrap:!0,children:[tX(tf)&&(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(K.A,{}),disabled:eY||eD,onClick:()=>{tf&&rl(tf)},children:"继续生成"}),(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(X.A,{}),disabled:eY,onClick:()=>{rd()},children:ev("documents.saveDraft")}),(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(J.A,{}),disabled:eY,loading:"markdown"===eV,onClick:()=>{ro("markdown")},children:"MD"}),(0,s.jsx)(m.Ay,{disabled:eY,loading:"html"===eV,onClick:()=>{ro("html")},children:"HTML"}),(0,s.jsx)(m.Ay,{disabled:eY,loading:"docx"===eV,onClick:()=>{ro("docx")},children:"DOCX"}),(0,s.jsx)(m.Ay,{type:"primary",disabled:eY,loading:"pdf"===eV,onClick:()=>{ro("pdf")},children:"PDF"})]}):tX(tf)||ri()||eD&&"workflow"===tk?(0,s.jsxs)(i.A,{wrap:!0,children:[tX(tf)&&(0,s.jsx)(m.Ay,{type:"primary",icon:(0,s.jsx)(K.A,{}),loading:eD,onClick:()=>{tf&&rl(tf)},children:"继续生成"}),ri()&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.Ay,{icon:(0,s.jsx)(J.A,{}),loading:"markdown"===eV,onClick:()=>{rc("markdown")},children:"MD"}),(0,s.jsx)(m.Ay,{loading:"html"===eV,onClick:()=>{rc("html")},children:"HTML"}),(0,s.jsx)(m.Ay,{loading:"docx"===eV,onClick:()=>{rc("docx")},children:"DOCX"}),(0,s.jsx)(m.Ay,{type:"primary",loading:"pdf"===eV,onClick:()=>{rc("pdf")},children:"PDF"})]}),eD&&"workflow"===tk&&(0,s.jsx)(m.Ay,{danger:!0,onClick:()=>{(async()=>{if(ea&&(en=!0),eU&&await (0,Y.r)(eU,tm||void 0).catch(()=>void 0),ea){var e;ea.aborted=!0,null==(e=ea.pollController)||e.abort(),ea.loading=!1,ea.error="用户中止",eo(),ea=null}for(let e of(localStorage.removeItem(tP),tF.current.values()))clearInterval(e);tF.current.clear(),eP(!1),th([]),tv(null),tA(!1),await tL(),ef.info("已中止生成任务")})()},children:"中止任务"})]}):void 0,children:(0,s.jsxs)(el,{style:{width:"100%"},gap:16,children:["workflow"===tk&&tx.length>0&&(0,s.jsx)(el,{gap:10,children:tx.map((e,t)=>{let r=tC.has(e.key),l=e.subSteps.length>8||e.description.length>240;return(0,s.jsxs)("div",{style:{display:"flex",gap:10,padding:10,border:"1px solid var(--colorBorderSecondary)",borderRadius:10,background:t===tH?"var(--colorFillAlter)":"var(--colorBgContainer)"},children:[(0,s.jsx)("span",{children:"process"===e.status?(0,s.jsx)(D.A,{}):"warning"===e.status?(0,s.jsx)(M.A,{style:{color:"var(--colorWarning)"}}):e.icon}),(0,s.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,s.jsxs)(i.A,{wrap:!0,children:[(0,s.jsx)(et,{strong:!0,children:e.title}),(0,s.jsx)(u.A,{color:"finish"===e.status?"success":"error"===e.status?"error":"warning"===e.status?"warning":"process"===e.status?"processing":"default",children:ev(ex[e.status])}),(e=>{var t;let r=ti.current.get(e.key);if(!r)return null;let l=t0((null!=(t=r.endedAt)?t:Date.now())-r.startedAt);return(0,s.jsx)(u.A,{className:"border-0 bg-[var(--colorFillSecondary)] m-0",children:r.endedAt?l:"".concat(l,"(运行中)")})})(e)]}),(0,s.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12,whiteSpace:"pre-wrap"},children:((e,t)=>{let r=e.description.length>240,l=t?e.subSteps:e.subSteps.slice(0,8);return(0,s.jsxs)("div",{children:[e.subtitle&&(0,s.jsx)("div",{style:{marginBottom:4},children:(0,s.jsx)(u.A,{children:e.subtitle})}),(0,s.jsx)("div",{style:!t&&r?{display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"}:void 0,children:e.description}),(0,s.jsx)("div",{style:{marginTop:4},children:l.map(e=>{var t;return(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,color:"process"===e.status?"var(--colorPrimary)":"var(--colorTextSecondary)"},children:["process"===(t=e.status)?(0,s.jsx)(D.A,{}):"finish"===t?(0,s.jsx)(P.A,{}):"warning"===t?(0,s.jsx)(M.A,{style:{color:"var(--colorWarning)"}}):"error"===t?(0,s.jsx)(L.A,{}):(0,s.jsx)("span",{style:{display:"inline-block",height:6,width:6,borderRadius:"50%",background:"var(--colorTextTertiary)"}}),(0,s.jsx)("span",{children:e.title})]},e.key)})})]})})(e,r)}),l&&(0,s.jsx)(m.Ay,{size:"small",type:"link",style:{padding:0,height:"auto",marginTop:6},onClick:()=>{var t;return t=e.key,void tN(e=>{let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),r})},children:r?"收起":e.subSteps.length>8?"更多(".concat(e.subSteps.length," 条详情)"):"更多"})]})]},e.key)})}),"workflow"===tk&&(null==tf?void 0:tf.partialChapters)&&tf.partialChapters.length>0&&(0,s.jsx)(v.A,{size:"small",title:"章节进度",extra:(0,s.jsxs)(u.A,{color:"blue",children:[tf.partialChapters.filter(e=>"completed"===e.status).length,"/",tf.partialChapters.length]}),children:(0,s.jsx)(el,{gap:6,style:{width:"100%"},children:tf.partialChapters.map(e=>(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:8,fontSize:12},children:[(0,s.jsx)(et,{ellipsis:!0,style:{maxWidth:480},children:e.title}),(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(u.A,{color:"failed"===e.status?"error":"success",children:"failed"===e.status?"失败":"完成"}),(0,s.jsxs)(et,{type:"secondary",children:[e.chars.toLocaleString()," 字"]})]})]},e.id))})}),"workflow"===tk&&(null==tf||null==(t=tf.draft)||null==(e=t.exportGate)?void 0:e.passed)===!1&&(()=>{var e;let t=(null==(e=tf.draft.exportGate.blockingIssues)?void 0:e.map(e=>e.message))||tf.draft.exportGate.checklist.filter(e=>!e.passed).map(e=>e.label)||["存在阻断级校验错误"],r=tI?t:t.slice(0,6);return(0,s.jsx)(es,{type:"error",title:"生成已完成,但导出门禁未通过",children:(0,s.jsxs)(i.A,{direction:"vertical",size:8,style:{width:"100%"},children:[(0,s.jsx)("span",{children:"阻断项:".concat(r.join(";")).concat(t.length>6&&!tI?"…(共 ".concat(t.length," 项)"):"","。可点击继续生成触发自动修复,或在“校验”页查看完整问题。")}),t.length>6&&(0,s.jsx)(m.Ay,{size:"small",type:"link",style:{padding:0,height:"auto",alignSelf:"flex-start"},onClick:()=>tT(e=>!e),children:tI?"收起":"查看全部 ".concat(t.length," 项")}),tX(tf)&&(0,s.jsx)(m.Ay,{type:"primary",size:"small",icon:(0,s.jsx)(K.A,{}),loading:eD,onClick:()=>{rl(tf)},children:"继续生成 / 自动修复"})]})})})(),"workflow"===tk&&(null==tf||null==(r=tf.reviewMetadata)?void 0:r.diagnostics)&&(0,s.jsx)(es,{type:"info",title:"后台自动优化",children:"策略:".concat(tf.reviewMetadata.diagnostics.strategy.mode,";LLM 调用 ").concat(tf.reviewMetadata.diagnostics.llm.calls," 次;噪声过滤 ").concat((null==(a=tf.reviewMetadata.diagnostics.evidence)?void 0:a.filteredNoise)||0," 条;质量门禁 阻断").concat((null==(o=tf.reviewMetadata.diagnostics.quality)?void 0:o.blockingCount)||0,"/重要").concat((null==(E=tf.reviewMetadata.diagnostics.quality)?void 0:E.importantCount)||0,"/轻微").concat((null==(F=tf.reviewMetadata.diagnostics.quality)?void 0:F.minorCount)||0,";自动限流调整 ").concat(tf.reviewMetadata.diagnostics.llm.limitAdjustments," 次。审查与诊断信息仅用于系统修复,不会写入正文或导出文件。")}),"workflow"===tk&&(null==tf||null==(B=tf.draft)?void 0:B.promptRules)&&(()=>{let e=tf.draft.promptRules,t=e.executionSummary||[],r=Object.entries(e.ruleSources||{}).filter(e=>{let[,t]=e;return t.length>0}),l=r.length>0,a=tR?r:r.slice(0,3);return(0,s.jsx)(v.A,{size:"small",title:(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(M.A,{style:{color:"var(--colorAccent)"}}),"提示词规则生效报告",t.length>0&&(0,s.jsxs)(u.A,{style:{margin:0},children:[t.length," 条"]})]}),styles:{body:{padding:12}},children:(0,s.jsxs)(el,{gap:6,children:[t.length>0&&t.map((e,t)=>(0,s.jsxs)("div",{style:{display:"flex",gap:6,fontSize:12,color:"var(--colorText)",lineHeight:1.6},children:[(0,s.jsx)(P.A,{style:{color:"var(--colorSuccess)",marginTop:4}}),(0,s.jsx)("span",{children:e})]},t)),l&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f.A,{style:{margin:"4px 0"}}),(0,s.jsx)(et,{type:"secondary",style:{fontSize:12},children:"规则溯源(自动从以下提示词中抽取):"}),a.map(e=>{let[t,r]=e;return(0,s.jsxs)("div",{style:{fontSize:12,color:"var(--colorTextSecondary)",lineHeight:1.6},children:[(0,s.jsx)(et,{strong:!0,style:{fontSize:12},children:t}),":",r.map(e=>"".concat(e.roleId,"「").concat(e.matchedText.length>24?"".concat(e.matchedText.slice(0,24),"…"):e.matchedText,"」")).join("、")]},t)}),r.length>3&&(0,s.jsx)(m.Ay,{size:"small",type:"link",style:{padding:0,height:"auto",alignSelf:"flex-start"},onClick:()=>tM(e=>!e),children:tR?"收起溯源":"查看全部溯源(".concat(r.length," 类)")})]}),!l&&0===t.length&&(0,s.jsx)(et,{type:"secondary",style:{fontSize:12},children:"未从提示词中识别到额外硬规则,使用系统默认质量规则。"})]})})})(),"workflow"===tk&&eD&&0===tx.length&&(0,s.jsxs)("div",{style:{textAlign:"center",padding:40},children:[(0,s.jsx)(j.A,{}),(0,s.jsx)("div",{style:{marginTop:12,color:"var(--colorTextSecondary)"},children:"正在准备生成…"})]}),"editor"===tk&&(null==eL?void 0:eL.reviewMetadata)&&(()=>{var e;let t=null==(e=eL.reviewMetadata.diagnostics)?void 0:e.quality,r=(eL.executionStages||[]).filter(e=>"llm_review"===e.type).flatMap(e=>(e.details||[]).filter(e=>/修复|补写|补齐|改进|调整/u.test(e))).slice(0,8);return t||0!==r.length?(0,s.jsx)(v.A,{size:"small",title:(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(P.A,{style:{color:"var(--colorSuccess)"}}),"运行质量报告"]}),styles:{body:{padding:12}},children:(0,s.jsxs)(el,{gap:8,children:[t&&(0,s.jsx)(i.A,{wrap:!0,size:6,children:(0,s.jsxs)(u.A,{color:t.blockingCount>0?"error":"success",className:"border-0 m-0",children:["审查修复 ",t.repairedCount," 项 / 问题 ",t.blockingCount+t.importantCount+t.minorCount," 项"]})}),r.length>0&&(0,s.jsxs)("div",{className:"flex flex-col gap-1 rounded-lg border border-[var(--borderColor)] bg-[var(--colorFillQuaternary)] px-3 py-2",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-[var(--colorText)]",children:"修复记录(审查阶段自动修复的内容)"}),r.map((e,t)=>(0,s.jsxs)("span",{className:"text-xs text-[var(--colorTextSecondary)]",children:["\xb7 ",e]},t))]})]})}):null})(),"editor"===tk&&tu.length>0&&(0,s.jsx)(v.A,{size:"small",title:(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(J.A,{}),"导出闭环报告",(0,s.jsx)(u.A,{className:"border-0 bg-[var(--colorFillSecondary)] m-0",children:tu.length})]}),styles:{body:{padding:12}},children:(0,s.jsxs)(el,{gap:6,children:[[...tu].reverse().map((e,t)=>(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-[var(--borderColor)] bg-[var(--colorFillQuaternary)] px-3 py-2 text-xs",children:[(0,s.jsx)(et,{strong:!0,children:e.format.toUpperCase()}),(0,s.jsx)(u.A,{color:"blue",className:"border-0 m-0",children:new Date(e.exportedAt).toLocaleString()}),void 0!==e.durationMs&&(0,s.jsxs)("span",{className:"text-[var(--colorTextSecondary)]",children:["总用时 ",t0(e.durationMs)]}),void 0!==e.repairedCount&&(0,s.jsxs)("span",{className:"text-[var(--colorTextSecondary)]",children:["修复 ",e.repairedCount," 项",void 0!==e.blockingCount?"(阻断 ".concat(e.blockingCount,")"):""]}),e.ruleSummary&&e.ruleSummary.length>0&&(0,s.jsxs)("span",{className:"text-[var(--colorTextSecondary)]",children:["规则 ",e.ruleSummary.length," 条"]}),!1===e.gatePassed&&(0,s.jsx)(u.A,{color:"error",className:"border-0 m-0",children:"门禁未过"}),e.healthAlerts&&e.healthAlerts.length>0&&(0,s.jsxs)(u.A,{color:"warning",className:"border-0 m-0",children:["健康告警 ",e.healthAlerts.length]})]},"".concat(e.exportedAt,"-").concat(t))),(()=>{let e=function(e){let t=[],r=[];if(e.length<3)return{retireCandidates:t,constraintSuggestions:r};let s=[...e].sort((e,t)=>e.exportedAt-t.exportedAt),l=s.slice(-3),a=s.slice(0,-3),n=new Set;for(let e of[...a,...l])for(let t of Object.keys(e.repairHeat||{}))n.add(t);for(let e of n){let s=l.map(t=>{var r;return null==(r=t.repairHeat)?void 0:r[e]});if(a.some(t=>{var r,s,l;return(null!=(l=null==(s=t.repairHeat)||null==(r=s[e])?void 0:r.hits)?l:0)>0})&&s.every(e=>void 0!==e&&0===e.hits)&&t.push(e),s.every(e=>void 0!==e&&e.hits>0&&e.failed/e.hits>=.5)){let t=s.reduce((e,t)=>e+(t?t.failed/t.hits:0),0)/s.length;r.push("".concat(e,"|").concat((100*t).toFixed(0),"%|连续").concat(3,"次"))}}return{retireCandidates:t,constraintSuggestions:r}}(tu);return 0===e.retireCandidates.length&&0===e.constraintSuggestions.length?null:(0,s.jsxs)(es,{type:"info",title:"跨文档缺陷热力图",children:[e.retireCandidates.length>0&&(0,s.jsxs)("div",{children:["候选退役(连续 3 次零命中,可评估停用):",e.retireCandidates.map(e=>{let t=e.split("|")[0];return $[t]?"".concat($[t],"(").concat(e,")"):e}).join("、")]}),e.constraintSuggestions.length>0&&(0,s.jsxs)("div",{children:["建议加入写作硬约束(高命中且修复失败率高):",e.constraintSuggestions.map(e=>{let t=e.split("|")[0];return $[t]?"".concat($[t],"(").concat(e,")"):e}).join("、")]})]})})()]})}),eL&&(0,s.jsx)("div",{ref:ey,children:(0,s.jsx)(x.A,{items:[{key:"edit",label:ev("documents.edit"),children:(0,s.jsxs)(el,{gap:16,style:{width:"100%"},children:[(0,s.jsx)(ee,{rows:28,value:eG,disabled:eY,onSelect:e=>{var t,r,s;return e3({start:null!=(t=e.currentTarget.selectionStart)?t:0,end:null!=(s=null!=(r=e.currentTarget.selectionEnd)?r:e.currentTarget.selectionStart)?s:0})},onChange:e=>{var t,r,s;eH(e.target.value),e2(null),e5(null),e3({start:null!=(t=e.target.selectionStart)?t:0,end:null!=(s=null!=(r=e.target.selectionEnd)?r:e.target.selectionStart)?s:0})}}),(0,s.jsx)(v.A,{size:"small",style:{borderRadius:12,background:"linear-gradient(135deg, var(--colorFillAlter), var(--colorBgContainer))"},children:(0,s.jsxs)(el,{gap:16,style:{width:"100%"},children:[(0,s.jsxs)(i.A,{align:"start",style:{width:"100%",justifyContent:"space-between"},children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(i.A,{size:6,children:[(0,s.jsx)(z.A,{style:{color:"var(--colorAccent)"}}),(0,s.jsx)(et,{strong:!0,children:"精准修改"}),(0,s.jsx)(u.A,{color:"blue",children:"AI 辅助"})]}),(0,s.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12},children:"针对当前编辑内容补充更具体的要求,AI 会保留文档结构并按你的提示细化修改。"})]}),(0,s.jsxs)(m.Ay,{size:"small",icon:(0,s.jsx)(Q.A,{}),onClick:()=>te(e=>!e),disabled:0===e4.length,children:["历史版本 ",e4.length>0?e4.length:""]})]}),(0,s.jsx)(es,{type:"info",title:"系统只负责识别修改范围,不改写你的提示词;选中文字后优先只改选区,没有选区时按光标所在小节/章节定位。"}),(0,s.jsx)(ee,{rows:4,value:eX,disabled:eY,onChange:e=>{eJ(e.target.value),e2(null),e5(null)},placeholder:"例如:写细一点;润色这段;第七章补充高处作业和临电安全措施;把安全检查频次改成每周一次。"}),(0,s.jsxs)(i.A,{wrap:!0,style:{width:"100%",justifyContent:"space-between"},children:[(0,s.jsx)(i.A,{wrap:!0,children:["写细一点","更专业","只润色选区","补充可执行措施"].map(e=>(0,s.jsx)(m.Ay,{size:"small",disabled:eY,onClick:()=>eJ(t=>t?"".concat(t,";").concat(e):e),children:e},e))}),(0,s.jsx)(m.Ay,{type:"primary",icon:(0,s.jsx)(z.A,{}),loading:eY&&"planning"===e$,disabled:!eX.trim()||eY,onClick:()=>{rx()},children:"识别修改范围"})]}),e1&&!e6&&(0,s.jsx)(v.A,{size:"small",style:{borderRadius:10,borderColor:"var(--colorAccent)"},children:(0,s.jsxs)(el,{gap:8,style:{width:"100%"},children:[(0,s.jsxs)(i.A,{wrap:!0,children:[(0,s.jsx)(u.A,{color:"purple",children:e1.scope}),(0,s.jsx)(u.A,{color:"blue",children:e1.action}),(0,s.jsxs)(u.A,{color:e1.confidence>=.8?"green":"orange",children:["置信度 ",Math.round(100*e1.confidence),"%"]}),e1.targetTitle&&(0,s.jsx)(et,{strong:!0,children:e1.targetTitle})]}),(0,s.jsx)(et,{children:e1.summary}),(0,s.jsx)(et,{type:"secondary",style:{fontSize:12},children:"将按你的原始提示词执行,不添加额外编辑任务。"}),(0,s.jsxs)(i.A,{children:[(0,s.jsx)(m.Ay,{type:"primary",loading:eY&&"applying"===e$,onClick:()=>{rh(e1)},children:"执行并预览"}),(0,s.jsx)(m.Ay,{disabled:eY,onClick:()=>e2(null),children:"取消"})]})]})}),e6&&(0,s.jsx)(v.A,{size:"small",style:{borderRadius:10,borderColor:"var(--colorSuccess)"},children:(0,s.jsxs)(el,{gap:8,style:{width:"100%"},children:[(0,s.jsxs)(i.A,{wrap:!0,children:[(0,s.jsx)(u.A,{color:"green",children:"修改预览"}),(0,s.jsx)(et,{children:e6.summary||e6.plan.summary}),(0,s.jsxs)(u.A,{children:[e6.changedChars&&e6.changedChars>0?"+".concat(e6.changedChars):e6.changedChars," 字符"]})]}),(0,s.jsxs)(y.A,{gutter:12,children:[(0,s.jsxs)(w.A,{span:12,children:[(0,s.jsx)(et,{strong:!0,children:"修改前"}),(0,s.jsx)("div",{style:{marginTop:6,maxHeight:180,overflow:"auto",padding:10,borderRadius:8,background:"var(--colorFillAlter)",whiteSpace:"pre-wrap",fontSize:12},children:e6.beforeSnippet||"无片段预览"})]}),(0,s.jsxs)(w.A,{span:12,children:[(0,s.jsx)(et,{strong:!0,children:"修改后"}),(0,s.jsx)("div",{style:{marginTop:6,maxHeight:180,overflow:"auto",padding:10,borderRadius:8,background:"var(--colorFillAlter)",whiteSpace:"pre-wrap",fontSize:12},children:e6.afterSnippet||"无片段预览"})]})]}),(0,s.jsxs)(i.A,{children:[(0,s.jsx)(m.Ay,{type:"primary",onClick:()=>{e6&&(ru(e6.before,e6.prompt),eH(e6.markdown),rp(!0),ef.success("已应用精准修改"))},children:"应用到文档"}),(0,s.jsx)(m.Ay,{onClick:()=>e5(null),children:"返回计划"}),(0,s.jsx)(m.Ay,{danger:!0,onClick:()=>{e2(null),e5(null)},children:"放弃"})]})]})}),e9&&(0,s.jsx)("div",{style:{borderTop:"1px solid var(--colorBorderSecondary)",paddingTop:12},children:(0,s.jsx)(b.A,{size:"small",dataSource:e4,locale:{emptyText:"暂无历史版本"},renderItem:e=>(0,s.jsx)(b.A.Item,{actions:[(0,s.jsx)(m.Ay,{size:"small",disabled:eY,onClick:()=>{ru(eG,"恢复前版本"),eH(e.content),rp(!0),ef.success("已恢复历史版本")},children:"恢复"},"restore")],children:(0,s.jsx)(b.A.Item.Meta,{title:(0,s.jsxs)(i.A,{children:[(0,s.jsx)(et,{children:new Date(e.createdAt).toLocaleString()}),(0,s.jsx)(u.A,{children:e.prompt})]}),description:(0,s.jsx)(et,{type:"secondary",ellipsis:!0,children:e.content.replace(/\s+/gu," ").slice(0,120)})})})})})]})})]})},{key:"chapters-facts",label:"章节与事实",children:(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[eL.chapters.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsxs)(et,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["章节 (",eL.chapters.length,")"]}),(0,s.jsx)(b.A,{size:"small",dataSource:eL.chapters,renderItem:e=>(0,s.jsx)(b.A.Item,{children:(0,s.jsx)(b.A.Item.Meta,{title:e.title,description:"证据: ".concat(e.evidence.length," \xb7 缺失: ").concat(e.missingFacts.length)})})})]}),eL.structuredFacts.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsxs)(et,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["结构化事实 (",eL.structuredFacts.length,")"]}),(0,s.jsx)(A.A,{size:"small",column:1,bordered:!0,children:eL.structuredFacts.map((e,t)=>(0,s.jsxs)(A.A.Item,{label:e.key,children:[(0,s.jsx)("span",{children:e.value}),(0,s.jsx)(u.A,{style:{marginLeft:8},children:e.confidence.toFixed(2)}),(0,s.jsx)(et,{type:"secondary",style:{fontSize:11,marginLeft:8},children:e.sourceFile})]},t))})]})]})},{key:"sources-missing",label:"来源与缺失",children:(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)(et,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["引用来源 (",eL.sources.length,")"]}),0===eL.sources.length?(0,s.jsx)(h.A,{description:"暂无"}):(0,s.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:eL.sources.map(e=>(0,s.jsxs)(u.A,{color:"blue",children:[e.filePath," (",e.count,")"]},e.filePath))})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)(et,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["缺失项 (",eL.missingItems.length,")"]}),0===eL.missingItems.length?(0,s.jsx)(h.A,{description:"无缺失"}):(0,s.jsx)(b.A,{size:"small",dataSource:eL.missingItems,renderItem:e=>(0,s.jsx)(b.A.Item,{children:e})})]})]})},{key:"validation",label:"校验 (".concat(eL.validationIssues.length,")"),children:0===eL.validationIssues.length?(0,s.jsx)(h.A,{description:"校验通过"}):(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[eL.validationIssues.map(e=>(0,s.jsxs)("div",{style:{border:"1px solid var(--colorBorderSecondary)",borderRadius:8,padding:12},children:[(0,s.jsx)(u.A,{color:"error"===e.level?"error":"warning"===e.level?"warning":"blue",children:ev(eg[e.level])}),(0,s.jsx)("div",{style:{marginTop:6,whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-all",lineHeight:1.6},children:e.message}),e.suggestion&&(0,s.jsx)("div",{style:{marginTop:6,color:"var(--colorTextSecondary)",whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-all"},children:e.suggestion})]},"".concat(e.level,"-").concat(e.message))),eL.exportGate.checklist.length>0&&(0,s.jsxs)("div",{style:{marginTop:8},children:[(0,s.jsx)(et,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:"导出门禁"}),(0,s.jsx)(b.A,{size:"small",dataSource:eL.exportGate.checklist,renderItem:e=>(0,s.jsxs)(b.A.Item,{children:[(0,s.jsx)(et,{style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:e.label}),(0,s.jsx)(u.A,{color:e.passed?"success":"error",children:e.passed?"PASS":"FAIL"})]})})]})]})},{key:"stages",label:"执行阶段 (".concat(eL.executionStages.length,")"),children:(0,s.jsx)(b.A,{size:"small",dataSource:eL.executionStages,renderItem:e=>(0,s.jsxs)(b.A.Item,{children:[(0,s.jsx)(b.A.Item.Meta,{avatar:ei[e.type]||(0,s.jsx)(_.A,{}),title:(0,s.jsx)(et,{title:e.roleId,style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:"".concat(e.title||ep[e.type]||e.type," \xb7 ").concat(e.roleName||e.subtitle||tO(e.roleId))}),description:(0,s.jsx)(et,{type:"secondary",style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},children:e.message})}),(0,s.jsx)(u.A,{color:"success"===e.status?"success":"failed"===e.status?"error":"skipped"===e.status?"default":"warning",children:ev(eh[e.status])})]})})}]})})]})}),(0,s.jsx)(g.A,{title:ev("documents.templateEditor"),open:tt,onClose:()=>tr(!1),size:"large",mask:{closable:!1},styles:{body:{padding:20,overflow:"auto"},header:{borderBottom:"1px solid var(--colorBorderSecondary)"}},extra:(0,s.jsxs)(i.A,{children:[(0,s.jsx)(m.Ay,{onClick:()=>tr(!1),children:ev("common.cancel")}),(0,s.jsx)(m.Ay,{type:"primary",onClick:()=>{t3()},children:ev("common.save")})]}),children:(0,s.jsxs)(d.A,{form:ej,layout:"vertical",requiredMark:"optional",children:[(0,s.jsxs)(y.A,{gutter:12,children:[(0,s.jsx)(d.A.Item,{name:"id",hidden:!0,children:(0,s.jsx)(n.A,{})}),(0,s.jsx)(w.A,{xs:24,md:8,children:(0,s.jsx)(d.A.Item,{name:"name",label:ev("documents.templateName"),rules:[{required:!0}],children:(0,s.jsx)(n.A,{})})}),(0,s.jsx)(w.A,{xs:24,md:8,children:(0,s.jsx)(d.A.Item,{name:"category",label:ev("documents.templateCategory"),children:(0,s.jsx)(n.A,{})})}),(0,s.jsx)(w.A,{xs:24,md:8,children:(0,s.jsx)(d.A.Item,{name:"outputTitle",label:ev("documents.outputTitle"),children:(0,s.jsx)(n.A,{})})}),(0,s.jsx)(w.A,{xs:24,md:12,children:(0,s.jsx)(d.A.Item,{name:"description",label:ev("documents.templateDescription"),children:(0,s.jsx)(n.A,{})})})]}),(0,s.jsx)(d.A.Item,{name:"projectRoleConfigId",label:ev("documents.projectRoleConfig"),rules:[{required:!0,message:ev("documents.projectRoleConfigRequired")}],children:(0,s.jsx)(k.A,{showSearch:!0,placeholder:ev("documents.projectRoleConfigRequired"),options:tG})}),(0,s.jsxs)("div",{className:"mb-6",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(et,{strong:!0,className:"text-base text-[var(--colorText)] block mb-1",children:"项目资料包绑定"}),(0,s.jsx)("div",{className:"text-xs text-[var(--colorTextSecondary)]",children:"直接选择整个项目文件夹,系统会自动识别招标正文、清单、图纸、补疑等资料类型。"})]}),(0,s.jsx)(u.A,{color:"blue",className:"border-0",children:"按项目资料包"})]}),eE?(0,s.jsxs)("div",{className:"text-center py-8",children:[(0,s.jsx)(j.A,{}),(0,s.jsx)("div",{className:"mt-3 text-[var(--colorTextSecondary)] text-xs",children:"正在加载知识库文件…"})]}):0===eM.length?(0,s.jsx)(h.A,{image:h.A.PRESENTED_IMAGE_SIMPLE,description:"暂无知识库文件"}):(0,s.jsx)(d.A.Item,{name:"projectMaterialRoots",rules:[{required:!0,message:"请选择项目资料包"}],children:(0,s.jsx)(S.A,{treeData:eM,loadData:t5,fieldNames:{label:"rawTitle",value:"value",children:"children"},onChange:e=>{var t;return t=e.map(e=>String(e)),void ej.setFieldValue("projectMaterialRoots",ed(t))},treeCheckable:!0,showCheckedStrategy:S.A.SHOW_PARENT,placeholder:"点击这里选择项目文件夹...",style:{width:"100%"},listHeight:360,showSearch:!0,maxTagCount:"responsive",size:"large"})})]})]})})]})}}},e=>{e.O(0,[717,883,665,44,563,7,787,195,455,506,65,636,593,792],()=>e(e.s=16403)),_N_E=e.O()}]);
|
|
File without changes
|