@customize-agent/server 4.0.108 → 4.0.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +27 -27
  3. package/.next/prerender-manifest.json +3 -3
  4. package/.next/server/chunks/1928.js +1 -1
  5. package/.next/server/chunks/1936.js +1 -1
  6. package/.next/server/chunks/6041.js +10 -8
  7. package/.next/server/chunks/8204.js +1 -1
  8. package/.next/server/middleware-build-manifest.js +1 -1
  9. package/.next/server/pages/404.html +1 -1
  10. package/.next/server/pages/500.html +1 -1
  11. package/.next/server/pages/api/kb/files/tree.js +5 -0
  12. package/.next/server/pages/api/kb/files/tree.js.nft.json +1 -0
  13. package/.next/server/pages/asset-library.html +1 -1
  14. package/.next/server/pages/document-roles.html +1 -1
  15. package/.next/server/pages/documents.html +1 -1
  16. package/.next/server/pages/guide.html +1 -1
  17. package/.next/server/pages/index.html +1 -1
  18. package/.next/server/pages/knowledge/file-detail.html +1 -1
  19. package/.next/server/pages/knowledge/files.html +1 -1
  20. package/.next/server/pages/knowledge/manage.html +1 -1
  21. package/.next/server/pages/knowledge.html +1 -1
  22. package/.next/server/pages/models.html +1 -1
  23. package/.next/server/pages/overview.html +1 -1
  24. package/.next/server/pages/prompt.html +1 -1
  25. package/.next/server/pages/settings.html +1 -1
  26. package/.next/server/pages/system/logs.html +1 -1
  27. package/.next/server/pages-manifest.json +28 -27
  28. package/.next/static/WFPMB0O5frURgkh5Qa8-n/_buildManifest.js +1 -0
  29. package/.next/static/chunks/{289-789ef042acd53608.js → 289-39ef5df8097382b4.js} +23 -23
  30. package/.next/static/chunks/497-58fdc9f4b4437f94.js +4 -0
  31. package/.next/static/chunks/713-efe6b531f7a30a5f.js +1 -0
  32. package/.next/static/chunks/795-e18d1f7843b8f683.js +1 -0
  33. package/.next/static/chunks/pages/_app-45a68e88c43b4f2c.js +212 -0
  34. package/.next/static/chunks/pages/asset-library-994e1e2977b6cf1b.js +1 -0
  35. package/.next/static/chunks/pages/{document-roles-aa320afdbc2edc5e.js → document-roles-17247e9639a04648.js} +1 -1
  36. package/.next/static/chunks/pages/documents-e79320e8cb87a955.js +1 -0
  37. package/.next/static/chunks/pages/knowledge/file-detail-73678bce1bb43f02.js +1 -0
  38. package/.next/static/chunks/pages/knowledge/files-f72277ef4a72bff0.js +1 -0
  39. package/.next/static/chunks/pages/knowledge/{manage-1363f53928abf98c.js → manage-b07ce5086d63ca67.js} +1 -1
  40. package/.next/static/chunks/pages/models-ec554ec972763d7b.js +1 -0
  41. package/.next/static/chunks/pages/prompt-11aab3e22cca2bdd.js +1 -0
  42. package/.next/static/chunks/pages/system/logs-91bfbc6fe9343d2e.js +1 -0
  43. package/.next/static/css/725551a791210988.css +1 -0
  44. package/.next/static/css/ad5a592c79d1448b.css +1 -0
  45. package/messages/en-US.json +147 -3
  46. package/messages/zh-CN.json +150 -6
  47. package/package.json +4 -4
  48. package/.next/static/chunks/375-1e1be370b94c7512.js +0 -1
  49. package/.next/static/chunks/651-b650f9bca2edf976.js +0 -4
  50. package/.next/static/chunks/795-ed2375ec938022d8.js +0 -1
  51. package/.next/static/chunks/pages/_app-d98d9d52c6257579.js +0 -212
  52. package/.next/static/chunks/pages/asset-library-dda51e0651d970ed.js +0 -1
  53. package/.next/static/chunks/pages/documents-5f3e8e1439988355.js +0 -1
  54. package/.next/static/chunks/pages/knowledge/file-detail-5c2b9a22d3d521e0.js +0 -1
  55. package/.next/static/chunks/pages/knowledge/files-57f72cae47532ab9.js +0 -1
  56. package/.next/static/chunks/pages/models-5d75c007cb2e8c25.js +0 -1
  57. package/.next/static/chunks/pages/prompt-87eeee86405f1356.js +0 -1
  58. package/.next/static/chunks/pages/system/logs-05259fa91f2e0903.js +0 -1
  59. package/.next/static/css/029ff7574443cc55.css +0 -1
  60. package/.next/static/css/df824e8d8cadbeb1.css +0 -1
  61. package/.next/static/wkCOJRi841-n7F2_lCGdW/_buildManifest.js +0 -1
  62. /package/.next/static/{wkCOJRi841-n7F2_lCGdW → WFPMB0O5frURgkh5Qa8-n}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[958],{63806:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>S});var n=a(65321),r=a(97109),s=a(17807),l=a(25258),i=a(88762),o=a(33442),c=a(85114),d=a(84253),p=a(21289),m=a(384),h=a(11702),x=a(71102),u=a(58209),y=a(75548),g=a(56768),w=a(93051),j=a(81668),v=a(64254),f=a(85855),k=a(48321),A=a(6578);let b={knowledge_base:"知识库",generated:"AI生成",uploaded:"上传",external_url:"外部URL"},N={cover:"magenta",reference:"blue",generated:"purple",attachment:"cyan",map:"orange",operator:"geekblue"};function S(){let e=(0,k.Vr)(),{message:t}=s.A.useApp(),[a,S]=(0,r.useState)([]),[C,T]=(0,r.useState)(new Set),[_,I]=(0,r.useState)(!0),[z,R]=(0,r.useState)(""),D=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:z;try{S((await (0,A.f$)(e||void 0)).assets)}catch(e){S([])}};(0,r.useEffect)(()=>{let e=!1;return I(!0),(0,A.dx)().then(t=>{var a,n,r;if(e)return;let s=(null==(a=t.find(e=>e.selected))?void 0:a.projectRoot)||(null==(n=t.find(e=>e.isCurrent))?void 0:n.projectRoot)||(null==(r=t[0])?void 0:r.projectRoot)||"";return R(s),D(s)}).finally(()=>{e||I(!1)}),()=>{e=!0}},[]);let E=async e=>{var a;e&&(await (null==(a=navigator.clipboard)?void 0:a.writeText(e)),t.success("已复制路径"))},F=async(e,a)=>{try{"openFile"===a?await (0,A.oS)(e,"file",z||void 0):"openDirectory"===a?await (0,A.oS)(e,"directory",z||void 0):"delete"===a&&(S((await (0,A.JU)(e,z||void 0)).assets),T(t=>{let a=new Set(t);return a.delete(e),a}))}catch(e){t.error(e instanceof Error?e.message:"操作失败")}},P=n=>{let r="selected"===n?[...C]:a.map(e=>e.id);0!==r.length&&l.A.confirm({title:"all"===n?"删除全部资源?":"删除已选 ".concat(r.length," 个资源?"),content:"此操作不可撤销。",okText:e("common.confirm"),cancelText:e("common.cancel"),okButtonProps:{danger:!0},onOk:async()=>{I(!0);try{await Promise.all(r.map(e=>(0,A.JU)(e,z||void 0))),await D(),T(new Set),t.success("已删除 ".concat(r.length," 个资源"))}catch(e){t.error("批量删除失败")}finally{I(!1)}}})};return _?(0,n.jsx)("div",{className:"space-y-5 animateFadeIn",children:(0,n.jsx)(i.A,{active:!0,title:!0,paragraph:{rows:8}})}):(0,n.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:12},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"pageTitle",children:e("nav.assetLibrary")}),(0,n.jsx)("p",{className:"pageDesc",children:"管理模板运行生成的文档、图片和附件。生成结果仅保存在生成资源中,不进入知识库。"})]}),(0,n.jsxs)(o.A,{size:8,children:[(0,n.jsxs)("span",{style:{color:"var(--colorTextSecondary)",fontSize:12},children:["共 ",a.length," 个资源"]}),(0,n.jsxs)(c.Ay,{danger:!0,size:"small",disabled:0===C.size,icon:(0,n.jsx)(u.A,{}),onClick:()=>P("selected"),children:["删除已选 ",C.size||""]}),(0,n.jsx)(c.Ay,{danger:!0,size:"small",disabled:0===a.length,onClick:()=>P("all"),children:"删除全部"})]})]}),0===a.length?(0,n.jsx)(d.A,{description:"暂无生成资源"}):(0,n.jsx)(p.A,{className:"modern-table",rowKey:"id",size:"middle",dataSource:a,pagination:{pageSize:12,showSizeChanger:!0,pageSizeOptions:[12,24,48],showTotal:e=>"共 ".concat(e," 个资源")},rowSelection:{selectedRowKeys:[...C],onChange:e=>T(new Set(e.map(String)))},columns:[{title:"资源",dataIndex:"name",key:"name",width:360,render:(e,t)=>{let a="image"===t.type&&t.path?"/api/assets/generated/preview?id=".concat(encodeURIComponent(t.id)).concat(z?"&projectRoot=".concat(encodeURIComponent(z)):""):void 0;return(0,n.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,n.jsx)("div",{className:"w-12 h-12 rounded-lg bg-[var(--colorBgHover)] flex items-center justify-center overflow-hidden shrink-0",children:a?(0,n.jsx)(m.A,{src:a,alt:t.name,width:48,height:48,style:{objectFit:"cover"},preview:!1}):"image"===t.type?(0,n.jsx)(y.A,{className:"text-[var(--colorWarning)]"}):(0,n.jsx)(g.A,{className:"text-[var(--colorAccent)]"})}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"font-medium text-[var(--colorText)] whitespace-normal break-words leading-snug",children:t.name}),(0,n.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1",children:[(0,n.jsx)(h.A,{color:N[t.role]||"blue",bordered:!1,className:"m-0",children:t.role}),(0,n.jsx)(h.A,{bordered:!1,className:"m-0",children:t.type})]})]})]})}},{title:"路径",dataIndex:"path",key:"path",render:e=>e?(0,n.jsx)("span",{className:"font-mono text-xs text-[var(--colorTextSecondary)] whitespace-normal break-all",children:e}):(0,n.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"-"})},{title:"来源",dataIndex:"source",key:"source",width:110,render:e=>(0,n.jsx)(h.A,{bordered:!1,className:"m-0",children:b[e]||e})},{title:"使用文档",dataIndex:"usedByDocumentIds",key:"usedByDocumentIds",width:100,render:e=>(0,n.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:e.length})},{title:"更新时间",dataIndex:"updatedAt",key:"updatedAt",width:130,render:e=>(0,n.jsx)("span",{className:"text-[var(--colorTextSecondary)]",children:new Date(e).toLocaleDateString()})},{title:"操作",key:"actions",width:88,align:"right",render:(t,a)=>{let r=[...a.path?[{key:"copy",icon:(0,n.jsx)(w.A,{}),label:"复制路径",onClick:()=>{E(a.path)}}]:[],...a.path?[{key:"open",icon:(0,n.jsx)(j.A,{}),label:"打开文件",onClick:()=>{F(a.id,"openFile")}}]:[],...a.path?[{key:"folder",icon:(0,n.jsx)(v.A,{}),label:"打开目录",onClick:()=>{F(a.id,"openDirectory")}}]:[],{type:"divider"},{key:"delete",icon:(0,n.jsx)(u.A,{}),label:e("common.delete"),danger:!0,onClick:()=>{F(a.id,"delete")}}];return(0,n.jsx)(x.A,{menu:{items:r},trigger:["click"],placement:"bottomRight",children:(0,n.jsx)(c.Ay,{type:"text",size:"small",icon:(0,n.jsx)(f.A,{}),onClick:e=>e.stopPropagation()})})}}]})]})}},85015:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/asset-library",function(){return a(63806)}])}},e=>{e.O(0,[433,985,375,289,238,636,593,792],()=>e(e.s=85015)),_N_E=e.O()}]);
@@ -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(19562)}])},19562:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>ed});var l=r(65321),s=r(97109),n=r(7576),a=r(35292),o=r(33442),i=r(11702),c=r(17807),d=r(63455),u=r(88762),p=r(85114),m=r(68787),h=r(84253),x=r(38332),g=r(26171),f=r(34052),v=r(42700),j=r(58569),y=r(2256),w=r(38770),A=r(76506),b=r(57271),S=r(49604),k=r(85493),I=r(23216),C=r(26619),T=r(8263),z=r(16285),R=r(8579),E=r(75548),B=r(7851),M=r(84742),N=r(29071),_=r(63552),F=r(26631),D=r(7225),P=r(83914),L=r(58209),W=r(54746),G=r(71330),O=r(64068),H=r(93051),q=r(38762),K=r(64629),V=r(67547),U=r(76830),X=r(1310),Q=r(6578),J=r(48321);let{TextArea:Y}=n.A,{Text:Z}=a.A;function $(e){let{type:t="info",title:r,children:s,style:n}=e,a="error"===t?"var(--colorError)":"warning"===t?"var(--colorWarning)":"success"===t?"var(--colorSuccess)":"var(--colorInfo)";return(0,l.jsxs)("div",{style:{border:"1px solid ".concat(a),background:"error"===t?"var(--colorErrorBg)":"warning"===t?"var(--colorWarningBg)":"success"===t?"var(--colorSuccessBg)":"var(--colorInfoBg)",borderRadius:8,padding:"9px 12px",...n},children:[(0,l.jsx)(Z,{strong:!0,style:{color:a},children:r}),s&&(0,l.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12},children:s})]})}function ee(e){let{children:t,gap:r=12,style:s}=e;return(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:r,...s},children:t})}let et=null;function er(){null==et||et.listeners.forEach(e=>e())}let el={role_binding:(0,l.jsx)(I.A,{}),knowledge_retrieval:(0,l.jsx)(C.A,{}),file_understanding:(0,l.jsx)(T.A,{}),fact_extraction:(0,l.jsx)(z.A,{}),chapter_generation:(0,l.jsx)(R.A,{}),asset_generation:(0,l.jsx)(E.A,{}),validation:(0,l.jsx)(B.A,{}),formatting:(0,l.jsx)(M.A,{}),llm_review:(0,l.jsx)(N.A,{}),export_ready:(0,l.jsx)(_.A,{}),reference:(0,l.jsx)(E.A,{})},es={施工组织设计:(0,l.jsx)(B.A,{}),投标文件:(0,l.jsx)(_.A,{}),技术方案:(0,l.jsx)(z.A,{}),报告:(0,l.jsx)(F.A,{}),自定义:(0,l.jsx)(R.A,{})};function en(e){return[...new Set(e.map(e=>e.trim()).filter(Boolean))]}function ea(e){return e?e.split(/[\\/]/u).pop()||e:""}function eo(e){let t=[],r=e=>{for(let l of e)l.isFolder?l.children&&r(l.children):t.push(l.key)};return r(e),t}let ei={role_binding:"角色配置绑定",knowledge_retrieval:"知识库检索",file_understanding:"多模态文件理解",fact_extraction:"LLM 事实抽取",chapter_generation:"LLM 章节生成",asset_generation:"多模态资源生成",validation:"规则校验",formatting:"格式化排版",llm_review:"LLM 审查优化",export_ready:"导出就绪",reference:"参考资源处理"},ec={"knowledge-base":"知识库","document-readiness":"生成准备度检查","quality-repair":"质量补写","export-gate":"导出门禁","context-memory":"项目上下文","final-format":"正式排版","multimodal-files":"多模态文件理解",tender_announcement:"招标公告"};function ed(){var e,t,r,a,E;let ed=(0,J.Vr)(),{message:eu}=c.A.useApp(),[ep]=d.A.useForm(),em=(0,s.useRef)(null),[eh,ex]=(0,s.useState)([]),[eg,ef]=(0,s.useState)("construction-organization-design"),[ev,ej]=(0,s.useState)([]),[ey,ew]=(0,s.useState)([]),[eA,eb]=(0,s.useState)([]),[eS,ek]=(0,s.useState)([]),[eI,eC]=(0,s.useState)(!1),[eT,ez]=(0,s.useState)(""),[eR,eE]=(0,s.useState)(),[eB,eM]=(0,s.useState)([]),[eN,e_]=(0,s.useState)(!0),[eF,eD]=(0,s.useState)(!1),[eP,eL]=(0,s.useState)(null),[eW,eG]=(0,s.useState)(""),[eO,eH]=(0,s.useState)([]),[eq,eK]=(0,s.useState)(null),[eV,eU]=(0,s.useState)(null),[eX,eQ]=(0,s.useState)(""),[eJ,eY]=(0,s.useState)(!1),[eZ,e$]=(0,s.useState)("idle"),[e0,e1]=(0,s.useState)(null),[e2,e6]=(0,s.useState)(null),[e8,e4]=(0,s.useState)({start:0,end:0}),[e3,e5]=(0,s.useState)([]),[e7,e9]=(0,s.useState)(!1),[te,tt]=(0,s.useState)(!1),[tr,tl]=(0,s.useState)({}),ts=d.A.useWatch("projectRoleConfigId",ep),tn=(0,s.useMemo)(()=>ey.find(e=>e.id===ts),[ey,ts]),ta=(0,s.useMemo)(()=>new Set(((null==tn?void 0:tn.fileRoles)||[]).map(e=>e.roleId)),[tn]),to=(0,s.useMemo)(()=>ev.filter(e=>"file"===e.type&&(!ts||ta.has(e.id))).map(e=>({label:e.name,value:e.id})),[ev,ta,ts]),ti=(0,s.useMemo)(()=>to.find(e=>e.value===eR)||to[0],[eR,to]),tc=d.A.useWatch("fileBindingGroups",ep)||{},td=(0,s.useMemo)(()=>(function(e){let t={};for(let s of[...e].sort((e,t)=>e.relativePath.localeCompare(t.relativePath,"zh-CN"))){let e=s.relativePath.split("/").filter(Boolean),n="";for(let a=0;a<e.length;a++){let i=e[a],c=n;n=n?"".concat(n,"/").concat(i):i;let d=a===e.length-1;if(!t[n]){var r;t[n]={key:n,rawTitle:i,title:d?(0,l.jsx)("span",{title:s.relativePath,children:i}):(0,l.jsxs)(o.A,{size:4,children:[(0,l.jsx)(D.A,{style:{color:"#faad14"}}),(0,l.jsx)("span",{children:i})]}),isFolder:!d,fileCount:+!!d,...d?{}:{children:[]}},c&&(null==(r=t[c])?void 0:r.children)&&t[c].children.push(t[n])}d&&(t[n].fileCount=1)}}let s=e=>{for(let r of e){var t;(null==(t=r.children)?void 0:t.length)&&(s(r.children),r.fileCount=r.children.reduce((e,t)=>e+t.fileCount,0),r.title=(0,l.jsxs)(o.A,{size:4,children:[(0,l.jsx)(D.A,{style:{color:"#faad14"}}),(0,l.jsx)("span",{children:r.rawTitle}),(0,l.jsx)(i.A,{style:{margin:0},children:r.fileCount})]}))}},n=Object.values(t).filter(e=>!e.key.includes("/"));return s(n),n.filter(e=>!e.isFolder||e.fileCount>0)})(eS),[eS]),tu=(0,s.useMemo)(()=>(function e(t,r){let l=r.trim().toLowerCase();return l?t.flatMap(t=>{let r=t.children?e(t.children,l):void 0;return t.key.toLowerCase().includes(l)||t.rawTitle.toLowerCase().includes(l)||(null==r?void 0:r.length)?[{...t,children:r}]:[]}):t})(td,eT),[td,eT]),tp=(0,s.useMemo)(()=>eo(td),[td]),tm=(0,s.useMemo)(()=>{var e,t,r;return(null==(e=eA.find(e=>e.selected))?void 0:e.projectRoot)||(null==(t=eA.find(e=>e.isCurrent))?void 0:t.projectRoot)||(null==(r=eA[0])?void 0:r.projectRoot)||""},[eA]),th=(0,s.useMemo)(()=>{let e=[],t=r=>{for(let l of r)e.push(l.key),l.children&&t(l.children)};return t(td),e},[td]);(0,s.useEffect)(()=>{if(!te||!ts)return;let e=ep.getFieldValue("fileBindingGroups")||{},t=Object.fromEntries(Object.entries(e).filter(e=>{let[t]=e;return ta.has(t)}));Object.keys(t).length!==Object.keys(e).length&&ep.setFieldValue("fileBindingGroups",t)},[ep,ta,ts,te]),(0,s.useEffect)(()=>{if(te){if(0===to.length)return void eE(void 0);eR&&to.some(e=>e.value===eR)||eE(to[0].value)}},[eR,to,te]);let[tx,tg]=(0,s.useState)([]),[tf,tv]=(0,s.useState)(null),[tj,ty]=(0,s.useState)(null),[tw,tA]=(0,s.useState)("templates"),[tb,tS]=(0,s.useState)(!1),[tk,tI]=(0,s.useState)("workflow"),tC=(0,s.useRef)(null),tT=(0,s.useRef)(null),tz=(0,s.useRef)(0),tR=(0,s.useMemo)(()=>"activeGenDocId:".concat(tm||"default"),[tm]),tE=async()=>{try{eH((await (0,Q.cQ)(tm||void 0)).documents)}catch(e){eH([])}};(0,s.useEffect)(()=>{let e=()=>{et&&(tg(et.flowSteps),tv(et.activeFlowKey),eD(et.loading),et.documentId&&eK(et.documentId),et.draft&&eL(et.draft),void 0!==et.content&&eG(et.content))},t=et;return null==t||t.listeners.add(e),e(),()=>{null==t||t.listeners.delete(e)}},[]),(0,s.useEffect)(()=>{e_(!0),Promise.all([(0,Q.Dl)().then(e=>{var t,r;ex(e.templates),ef(null!=(r=null==(t=e.templates[0])?void 0:t.id)?r:"construction-organization-design")}),(0,Q.lv)().then(e=>{ej(e.roles),ew(e.configs)}),(0,Q.dx)().then(e=>eb(e))]).catch(()=>eu.error(ed("common.error"))).finally(()=>e_(!1))},[eu,ed]),(0,s.useEffect)(()=>{tm&&(localStorage.removeItem("activeGenDocId"),tE())},[tm]),(0,s.useEffect)(()=>{if(0===eO.length)return;let e=localStorage.getItem(tR);if(!e)return;if(!eO.find(t=>t.id===e&&"generating"===t.status))return void localStorage.removeItem(tR);let t=setInterval(()=>{(async()=>{try{let{document:r}=await (0,Q.v7)(e,!1,tm||void 0);await tE(),"generating"!==r.status&&(localStorage.removeItem(tR),clearInterval(t))}catch(e){clearInterval(t)}})()},3e3);return()=>clearInterval(t)},[eO]);let tB=(0,s.useMemo)(()=>eh.find(e=>e.id===eg),[eh,eg]),tM=ey.map(e=>({label:e.name,value:e.id})),tN=Math.max(0,tx.findIndex(e=>e.key===tf)),t_=e=>{var t;return e?(null==(t=ev.find(t=>t.id===e))?void 0:t.name)||ec[e]||"未知角色":""},tF=e=>e.subtitle||e.roleName||t_(e.roleId)||ei[e.type]||e.type,tD=e=>{var t,r,l;return e.promptName||((t=e.promptId)?(null==(r=eA.find(e=>e.id===t))?void 0:r.projectName)||(null==(l=ev.find(e=>e.id===t))?void 0:l.name)||ec[t]||"未知提示词":"")},tP=()=>{tz.current+=1,eQ(""),e1(null),e6(null),e5([]),e9(!1),eY(!1),e$("idle")},tL=e=>{ef(e),eK(null),eL(null),eG(""),tP(),tI("workflow"),tS(!0),tA("drafts")},tW=async e=>{eK(e.id),ef(e.templateId);let t=tG(e.status);if(t||"failed"===e.status||"aborted"===e.status){tP(),ty(e),eL(null),eG(""),eD(t),tI("workflow"),tS(!0);try{let{document:t}=await (0,Q.v7)(e.id,!1,e.projectRoot||tm||void 0);tq(t),tG(t.status)?tK(t.id,t.projectRoot||e.projectRoot||tm||void 0):await tE()}catch(t){tq(e)}return}tI("editor"),tg([]),tv(null),tP();try{let{document:t}=await (0,Q.v7)(e.id,!1,e.projectRoot||tm||void 0);eL(t.draft||null),eG(t.editedMarkdown||t.markdown)}catch(e){eu.error(ed("common.error"))}tS(!0)},tG=e=>"completed"!==e&&"warning"!==e&&"failed"!==e&&"aborted"!==e,tO=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:eF;(null==et?void 0:et.loading)&&(et.flowSteps=e,et.activeFlowKey=t,et.loading=r,er())},tH=e=>{var t,r,s,n,a;let o=e.executionStages||(null==(t=e.draft)?void 0:t.executionStages)||[];if(o.length>0){let t=o.map((t,r)=>{var s;let n,a=("failed"===e.status||"aborted"===e.status)&&"running"===t.status||"failed"===(n=t.status)?"error":"running"===n?"process":"fallback"===n?"warning":"finish";return{key:"".concat(t.type,"-").concat(r),title:t.title||ei[t.type]||t.type,subtitle:tF(t),description:t.message||"",status:a,icon:"role_binding"===(s=t.type)?(0,l.jsx)(I.A,{}):"knowledge_retrieval"===s?(0,l.jsx)(C.A,{}):"file_understanding"===s?(0,l.jsx)(T.A,{}):"fact_extraction"===s?(0,l.jsx)(z.A,{}):"chapter_generation"===s?(0,l.jsx)(R.A,{}):"llm_review"===s?(0,l.jsx)(N.A,{}):"validation"===s?(0,l.jsx)(B.A,{}):"formatting"===s?(0,l.jsx)(M.A,{}):"export_ready"===s?(0,l.jsx)(_.A,{}):(0,l.jsx)(F.A,{}),subSteps:((e,t,r)=>{let l=Array.isArray(e.details)?e.details.filter(Boolean):[],s=e.progress?"".concat(e.progress.label||"进度",":").concat(e.progress.current,"/").concat(e.progress.total):"",n=[...s?[s]:[],...l];return 0===n.length?[{key:"stage-".concat(r),title:tD(e)?"提示词:".concat(tD(e)):tF(e),status:t}]:n.slice(0,8).map((e,l)=>({key:"stage-".concat(r,"-").concat(l),title:e,status:"process"===t&&0===l?"process":"error"===t&&0===l?"error":"warning"===t?"warning":"process"===t?"finish":t}))})(t,a,r)}});"generating"===e.status&&t.length>0&&(null==(r=t.at(-1))?void 0:r.status)==="finish"&&(t[t.length-1]={...t[t.length-1],status:"process"});let i="generating"===e.status?(null==(s=t.at(-1))?void 0:s.key)||"prepare":"failed"===e.status||"aborted"===e.status?(null==(n=t.find(e=>"error"===e.status))?void 0:n.key)||(null==(a=t.at(-1))?void 0:a.key)||"prepare":"done";return{steps:t,activeKey:i}}return{steps:[],activeKey:null}},tq=e=>{ty(e);let{steps:t,activeKey:r}=tH(e);tg(t),tv(r),eD(tG(e.status)),tO(t,r,tG(e.status)),("failed"===e.status||"aborted"===e.status)&&tI("workflow"),("completed"===e.status||"warning"===e.status)&&e.draft&&(eL(e.draft),eG(e.editedMarkdown||e.markdown),tI("editor"),tg([]),tv(null))},tK=(e,t)=>{tC.current&&clearInterval(tC.current),tC.current=setInterval(()=>{(async()=>{try{let{document:r}=await (0,Q.v7)(e,!0,t||tm||void 0);tq(r),await tE(),tG(r.status)||(tC.current&&clearInterval(tC.current),tC.current=null,localStorage.removeItem(tR))}catch(e){}})()},2e3)};(0,s.useEffect)(()=>()=>{tC.current&&(clearInterval(tC.current),tC.current=null),tT.current&&(clearTimeout(tT.current),tT.current=null)},[]),(0,s.useEffect)(()=>{if(!eF||!tf)return;let e=window.setInterval(()=>tg(e=>{let t=e.map(e=>{if(e.key!==tf||"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 tO(t,tf),t}),1400);return()=>window.clearInterval(e)},[tf,eF]);let tV=async()=>{eC(!0);try{let e=await (0,Q.HT)({limit:5e3,projectRoot:tm||void 0});ek(e.files)}catch(e){eu.error("知识库文件加载失败")}finally{eC(!1)}},tU=e=>{var t,r,l;let s=null!=e?e:{id:"tpl-".concat(Date.now()),name:"",description:"",category:"自定义",outputTitle:"",projectRoleConfigId:void 0,chapters:[],fileBindings:[]};ep.resetFields(),ep.setFieldsValue({...s,fileBindingGroups:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.reduce((e,t)=>(t.roleId&&t.filePath&&(e[t.roleId]=en([...e[t.roleId]||[],t.filePath])),e),{})}(s.fileBindings)}),eE(null==(l=ey.find(e=>e.id===s.projectRoleConfigId))||null==(r=l.fileRoles)||null==(t=r[0])?void 0:t.roleId),ez(""),tV(),tt(!0)},tX=(e,t)=>{let r=ep.getFieldValue("fileBindingGroups")||{};ep.setFieldValue("fileBindingGroups",{...r,[e]:en(t)})},tQ=async()=>{try{var e;await ep.validateFields();let t=ep.getFieldsValue(!0),r=new Set(((null==(e=ey.find(e=>e.id===t.projectRoleConfigId))?void 0:e.fileRoles)||[]).map(e=>e.roleId)),l=t.fileBindingGroups||{},s=Object.entries(l).filter(e=>{let[t]=e;return 0===r.size||r.has(t)}).flatMap(e=>{let[t,r]=e;return en(r||[]).map(e=>({roleId:t,filePath:e}))}),{fileBindingGroups:n,...a}=t,o={...a,chapters:[],fileBindings:s},i=await (0,Q.l2)(o);ex(i.templates),ef(i.template.id),tt(!1),await tE(),eu.success(ed("common.success"))}catch(e){e instanceof Error&&eu.error(e.message)}},tJ=async e=>{try{let t=await (0,Q.bV)(e);ex(t.templates),ef(t.template.id),eu.success(ed("common.success"))}catch(e){eu.error(ed("common.error"))}},tY=async e=>{try{var t,r;let l=await (0,Q.h0)(e);ex(l.templates),ef(null!=(r=null==(t=l.templates[0])?void 0:t.id)?r:""),eu.success(ed("common.success"))}catch(e){eu.error(ed("common.error"))}},tZ=async e=>{try{let{validation:t}=await (0,Q.SM)(e,tm||void 0);tl(r=>({...r,[e]:t}));let r=t.issues.filter(e=>"error"===e.level);if(ef(e),r.length>0)return void eu.warning("模板运行前检查未通过,请先处理阻断项");if(t.issues.length>0)return void eu.warning("模板存在警告,可在检查面板确认后继续运行");tL(e)}catch(e){eu.error(e instanceof Error?e.message:"模板运行前检查失败")}},t$=async e=>{try{await (0,Q.QG)(e.id,e.projectRoot||tm||void 0),eq===e.id&&(eK(null),eL(null),eG("")),await tE(),eu.success(ed("common.success"))}catch(e){eu.error(ed("common.error"))}},t0=async(e,t)=>{let r=Date.now(),l=0,s=Date.now();for(;;){let n;if(null==t?void 0:t.aborted)throw Error("用户中止");let a=new AbortController;t&&(t.pollController=a);try{({document:n}=await (0,Q.v7)(e,!0,tm||void 0,a.signal))}finally{(null==t?void 0:t.pollController)===a&&(t.pollController=void 0)}if(tq(n),n.updatedAt!==l&&(l=n.updatedAt,s=Date.now()),("completed"===n.status||"warning"===n.status)&&n.draft)return n;if("failed"===n.status||"aborted"===n.status)throw Error(n.error||("aborted"===n.status?"生成已中止":"生成失败"));if(Date.now()-r>75e5||Date.now()-s>96e4)throw Error("生成任务疑似卡住,请点击继续生成或重新生成");await new Promise(e=>window.setTimeout(e,1500))}},t1=async()=>{if(!eg)return;if((null==et?void 0:et.aborted)&&(et=null),null==et?void 0:et.loading){tg(et.flowSteps),tv(et.activeFlowKey),eD(!0);return}if(!tm)return void eu.error("未识别当前项目,请先选择或打开项目后再生成文件");eD(!0);let e=(0,Q.OX)({templateId:eg,projectRoot:tm});et={id:Date.now(),templateId:eg,loading:!0,flowSteps:[],activeFlowKey:null,promise:e,listeners:new Set},tg([]),tv(null);let t=[];try{let r=await e;r.documentId&&(localStorage.setItem(tR,r.documentId),eK(r.documentId),(null==et?void 0:et.promise)===e&&(et.documentId=r.documentId)),await tE();let l=r.documentId?await t0(r.documentId,(null==et?void 0:et.promise)===e?et:void 0):void 0,s=r.draft||(null==l?void 0:l.draft);if(!s)throw Error("生成结果为空");(r.documentId||(null==l?void 0:l.id))&&eK(r.documentId||l.id),t.forEach(e=>window.clearTimeout(e)),eL(s),eG((null==l?void 0:l.editedMarkdown)||(null==l?void 0:l.markdown)||s.markdown),(null==et?void 0:et.promise)===e&&(et.draft=s,et.content=(null==l?void 0:l.editedMarkdown)||(null==l?void 0:l.markdown)||s.markdown);let n=l||{id:r.documentId||"draft-".concat(Date.now()),templateId:eg,title:s.title,requirement:s.requirement,projectRoot:s.projectRoot||tm,projectId:s.projectId,markdown:s.markdown,status:s.validationIssues.some(e=>"error"===e.level||"warning"===e.level)||!s.exportGate.passed?"warning":"completed",draft:s,executionStages:s.executionStages,assets:s.assets||[],createdAt:s.generatedAt,updatedAt:Date.now()},{steps:a}=tH(n);tg(a),tO(a,"done",!1),tv("done"),(null==et?void 0:et.promise)===e&&(et.activeFlowKey="done",et.loading=!1,er(),et=null),localStorage.removeItem(tR),await tE(),eu.success(ed("common.success")),window.setTimeout(()=>{var e;return null==(e=em.current)?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},200)}catch(l){localStorage.removeItem(tR);let t=l instanceof Error?l.message:ed("common.error"),r=/用户中止|abort|aborted/i.test(t);r||tg(e=>{let r=e.map(e=>"process"===e.status?{...e,status:"error",description:t,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)})(e,"error")}:e);return tO(r,tf,!1),r}),(null==et?void 0:et.promise)===e&&(et.loading=!1,et.error=t,er(),et=null),await tE().catch(()=>void 0),r||eu.error(t)}finally{t.forEach(e=>window.clearTimeout(e)),eD(!1),(null==et?void 0:et.promise)===e&&(et.loading=!1,er())}},t2=(0,s.useRef)(!1);(0,s.useEffect)(()=>(tT.current&&(clearTimeout(tT.current),tT.current=null),!tb||"workflow"!==tk||eq||t2.current||(null==et?void 0:et.loading)||null==tB||!tB.projectRoleConfigId||(t2.current=!0,tT.current=setTimeout(()=>{tT.current=null,tb&&"workflow"===tk&&!eq&&eg==eg&&t1()},300)),tb||(t2.current=!1),()=>{tT.current&&(clearTimeout(tT.current),tT.current=null)}),[tb,tk,eq,tB,eg]);let t6=async e=>{try{eK(e.id),ef(e.templateId),tI("workflow"),tS(!0),eD(!0);let t=await (0,Q.UQ)(e.id,e.projectRoot||tm||void 0);localStorage.setItem(tR,t.documentId),await tE();let r=await t0(t.documentId);r.draft&&(eL(r.draft),eG(r.editedMarkdown||r.markdown||r.draft.markdown),tI("editor")),localStorage.removeItem(tR),await tE(),eu.success("已继续生成并完成")}catch(e){eu.error(e instanceof Error?e.message:"继续生成失败")}finally{eD(!1)}},t8=async e=>{if((null==et?void 0:et.loading)&&et.documentId===e.id){var t;et.aborted=!0,null==(t=et.pollController)||t.abort(),et.loading=!1,et.error="用户中止",er(),et=null,eD(!1)}localStorage.removeItem(tR),tC.current&&(clearInterval(tC.current),tC.current=null);try{await (0,Q.r)(e.id,e.projectRoot||tm||void 0),eu.success("已中止生成任务")}catch(e){eu.info("任务已不在运行,已刷新状态")}finally{await tE(),eq===e.id&&(eK(null),ty(null),eL(null),eG(""))}},t4=async e=>{if(eP){eU(e);try{eP.exportGate.passed||eu.warning("导出门禁存在风险项,已允许导出,请下载后人工复核。");let t={documentId:eq||void 0,title:eP.title,markdown:eW,format:e,enforceGate:!1,exportGate:eP.exportGate,useClientMarkdown:!0,projectRoot:eP.projectRoot||tm||void 0},r=await (0,Q.UE)(t);((e,t,r)=>{let l=new Blob([e],{type:r}),s=URL.createObjectURL(l),n=document.createElement("a");n.href=s,n.download=t,n.target="_self",n.rel="noopener",n.style.display="none",document.body.appendChild(n),n.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window})),n.remove(),window.setTimeout(()=>URL.revokeObjectURL(s),1e3)})(r,"".concat(eP.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])}catch(e){eu.error(e instanceof Error?e.message:ed("common.error"))}finally{eU(null)}}},t3=async()=>{if(eP)try{if(eq)await (0,Q.a6)(eq,{editedMarkdown:eW,markdown:eW},eP.projectRoot||tm||void 0);else{let e=await (0,Q.Af)({...eP,markdown:eW});eL(e.draft)}await tE(),eu.success(ed("common.success"))}catch(e){eu.error(ed("common.error"))}},t5=(e,t)=>{e5(r=>[{id:"".concat(Date.now()),content:e,prompt:t,createdAt:Date.now()},...r].slice(0,12))},t7=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e&&eQ(""),e1(null),e6(null),e4({start:0,end:0})},t9=(e,t)=>{var r,l;return{title:(null==eP?void 0:eP.title)||"未命名文档",markdown:t,instruction:e,facts:null==eP||null==(r=eP.structuredFacts)?void 0:r.map(e=>"".concat(e.key,": ").concat(e.value)),chapters:null==eP||null==(l=eP.chapters)?void 0:l.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}})()}},re=async()=>{let e=eX.trim();if(!eP||!e||eJ)return;let t=tz.current+1;tz.current=t,eY(!0),e$("planning"),e6(null);try{let r=await (0,Q.Gi)({mode:"plan",...t9(e,eW)});if(tz.current!==t||eq!=eq)return;if(!r.plan)throw Error("AI 未返回修改计划");e1(r.plan)}catch(e){tz.current===t&&eu.error(e instanceof Error?e.message:ed("common.error"))}finally{tz.current===t&&(eY(!1),e$("idle"))}},rt=async e=>{let t=eX.trim();if(!eP||!t||eJ)return;let r=tz.current+1;tz.current=r,eY(!0),e$("applying");try{let l=await (0,Q.Gi)({mode:"apply",...t9(t,eW),plan:e});if(tz.current!==r||eq!=eq)return;if(!l.markdown)throw Error("AI 未返回修改结果");e6({plan:l.plan||e,markdown:l.markdown,beforeSnippet:l.beforeSnippet,afterSnippet:l.afterSnippet,summary:l.summary,changedChars:l.changedChars,prompt:t,before:eW})}catch(e){tz.current===r&&eu.error(e instanceof Error?e.message:ed("common.error"))}finally{tz.current===r&&(eY(!1),e$("idle"))}};if(eN)return(0,l.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,l.jsx)(u.A,{active:!0,title:!0,paragraph:{rows:1}}),(0,l.jsx)(u.A,{active:!0,paragraph:{rows:2}}),(0,l.jsx)(u.A,{active:!0,paragraph:{rows:8}})]});let rr="workflow"===tk?"工作流:".concat((null==tB?void 0:tB.name)||"选择模板"):"编辑:".concat((null==eP?void 0:eP.title)||(null==tB?void 0:tB.outputTitle)||"文档");return(0,l.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:12},children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h1",{className:"pageTitle",children:ed("documents.title")}),(0,l.jsx)("p",{className:"pageDesc",children:ed("documents.description")})]}),(0,l.jsx)(p.Ay,{type:"primary",icon:(0,l.jsx)(W.A,{}),onClick:()=>tU(),children:ed("documents.newTemplate")})]}),(0,l.jsx)(m.A,{size:"small",tabList:[{key:"templates",label:"模板库 (".concat(eh.length,")")},{key:"drafts",label:"生成记录 (".concat(eO.length,")")}],activeTabKey:tw,onTabChange:tA,children:"templates"===tw?0===eh.length?(0,l.jsx)(h.A,{description:ed("common.noData")}):(0,l.jsx)(x.A,{dataSource:eh,renderItem:e=>{var t,r;return(0,l.jsx)(x.A.Item,{style:{cursor:"pointer",padding:"10px 0"},actions:[(0,l.jsx)(p.Ay,{size:"small",icon:(0,l.jsx)(G.A,{}),onClick:t=>{t.stopPropagation(),tU(e)},children:"配置"},"cfg"),(0,l.jsx)(p.Ay,{size:"small",type:"primary",icon:(0,l.jsx)(O.A,{}),onClick:t=>{t.stopPropagation(),tZ(e.id)},children:"运行"},"run"),(0,l.jsx)(p.Ay,{size:"small",icon:(0,l.jsx)(H.A,{}),onClick:t=>{t.stopPropagation(),tJ(e.id)}},"copy"),(0,l.jsx)(g.A,{title:ed("documents.deleteTemplateConfirm"),onConfirm:t=>{null==t||t.stopPropagation(),tY(e.id)},children:(0,l.jsx)(p.Ay,{size:"small",danger:!0,icon:(0,l.jsx)(L.A,{}),onClick:e=>e.stopPropagation()})},"del")],onClick:()=>ef(e.id),children:(0,l.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:10,minWidth:0,flex:1},children:[function(e,t){let r=es[e]||(0,l.jsx)(F.A,{});return(0,l.jsx)("span",{style:{color:t?"var(--colorAccent)":"var(--colorTextSecondary)",fontSize:16,marginTop:2,flexShrink:0},children:r})}(e.category,eg===e.id),(0,l.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2},children:[(0,l.jsx)("span",{style:{fontWeight:eg===e.id?600:400,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),eg===e.id&&(0,l.jsx)(i.A,{color:"blue",style:{margin:0,fontSize:10,lineHeight:"16px",flexShrink:0},children:"当前"}),(0,l.jsx)(i.A,{style:{margin:0,fontSize:10,lineHeight:"16px",flexShrink:0},children:e.category}),tr[e.id]&&(0,l.jsxs)(i.A,{color:tr[e.id].issues.some(e=>"error"===e.level)?"error":tr[e.id].issues.length?"warning":"success",style:{margin:0,fontSize:10,lineHeight:"16px",flexShrink:0},children:["检查 ",tr[e.id].fileDiagnostics.length," 文件 / ",tr[e.id].promptDiagnostics.length," 提示词"]})]}),e.description&&(0,l.jsx)(Z,{type:"secondary",style:{fontSize:12,lineHeight:"18px"},children:e.description}),tr[e.id]&&(0,l.jsx)("div",{onClick:e=>e.stopPropagation(),style:{marginTop:8,padding:10,border:"1px solid ".concat(tr[e.id].issues.some(e=>"error"===e.level)?"var(--colorErrorBorder)":tr[e.id].issues.length?"var(--colorWarningBorder)":"var(--colorSuccessBorder)"),borderRadius:10,background:tr[e.id].issues.some(e=>"error"===e.level)?"var(--colorErrorBg)":tr[e.id].issues.length?"var(--colorWarningBg)":"var(--colorSuccessBg)"},children:(0,l.jsxs)(ee,{gap:6,style:{width:"100%"},children:[(0,l.jsxs)(o.A,{wrap:!0,children:[(0,l.jsx)(Z,{strong:!0,children:tr[e.id].issues.some(e=>"error"===e.level)?"运行前检查未通过":tr[e.id].issues.length?"运行前检查存在警告":"运行前检查通过"}),(0,l.jsxs)(i.A,{color:"blue",children:["文件角色 ",tr[e.id].fileDiagnostics.length]}),(0,l.jsxs)(i.A,{color:"purple",children:["提示词角色 ",tr[e.id].promptDiagnostics.length]}),tr[e.id].readiness&&(0,l.jsxs)(i.A,{color:tr[e.id].readiness.ready?"green":"error",children:["资料覆盖 ",Math.round(100*tr[e.id].readiness.materialCoverageRate),"%"]}),tr[e.id].readiness&&(0,l.jsxs)(i.A,{color:"cyan",children:["角色满足 ",Math.round(100*tr[e.id].readiness.roleSatisfactionRate),"%"]}),tr[e.id].readiness&&(0,l.jsxs)(i.A,{color:"geekblue",children:["规范完整 ",Math.round(100*tr[e.id].readiness.specCompletenessRate),"%"]})]}),null==(r=tr[e.id].readiness)||null==(t=r.chapterDiagnostics)?void 0:t.filter(e=>e.readinessRate<.7||e.missingFacts.length>0).slice(0,5).map(e=>(0,l.jsx)($,{type:e.readinessRate<.5?"warning":"info",title:"章节预检:".concat(e.title," \xb7 覆盖 ").concat(Math.round(100*e.readinessRate),"% \xb7 证据 ").concat(e.evidenceCount," 条").concat(e.missingFacts.length?" \xb7 缺失 ".concat(e.missingFacts.slice(0,4).join("、")):"")},e.chapterId)),tr[e.id].issues.length>0?tr[e.id].issues.map(e=>(0,l.jsx)($,{type:"error"===e.level?"error":"warning",title:e.message},e.message)):(0,l.jsx)($,{type:"success",title:"文件角色、提示词角色和后台自动规范检查通过,可以运行。"}),!tr[e.id].issues.some(e=>"error"===e.level)&&tr[e.id].issues.length>0&&(0,l.jsx)("div",{children:(0,l.jsx)(p.Ay,{size:"small",type:"primary",icon:(0,l.jsx)(O.A,{}),onClick:()=>tL(e.id),children:"忽略警告并继续运行"})})]})})]})]})})}}):0===eO.length?(0,l.jsx)(h.A,{description:ed("common.noData")}):(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:eO.slice(0,15).map((e,t)=>{var r,s,n,a,c;let d,u;return(0,l.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"10px 12px",border:"1px solid var(--colorBorderSecondary)",borderRadius:10,cursor:"pointer",background:eq===e.id?"var(--colorFillAlter)":void 0,minWidth:0},onClick:()=>{tW(e)},children:["completed"===e.status?(0,l.jsx)(M.A,{style:{fontSize:18,color:"var(--colorOk)",flexShrink:0,marginTop:2}}):"failed"===e.status||"aborted"===e.status?(0,l.jsx)(q.A,{style:{fontSize:18,color:"var(--colorDanger)",flexShrink:0,marginTop:2}}):"warning"===e.status?(0,l.jsx)(B.A,{style:{fontSize:18,color:"var(--colorWarning)",flexShrink:0,marginTop:2}}):(0,l.jsx)(K.A,{spin:!0,style:{fontSize:18,color:"#1677ff",flexShrink:0,marginTop:2}}),(0,l.jsxs)("div",{style:{minWidth:0,flex:1},children:[(0,l.jsx)("div",{style:{fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginBottom:3},children:e.title}),(0,l.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 10px",color:"var(--colorTextSecondary)",fontSize:11},children:[(0,l.jsx)("span",{children:new Date(e.updatedAt).toLocaleString()}),(0,l.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),l=t%60;if(r<60)return l?"".concat(r," 分 ").concat(l," 秒"):"".concat(r," 分");let s=Math.floor(r/60),n=r%60;return n?"".concat(s," 小时 ").concat(n," 分"):"".concat(s," 小时")})(e)]})]}),e.partialChapters&&e.partialChapters.length>0&&(0,l.jsxs)("div",{style:{marginTop:3,fontSize:11,color:"var(--colorTextSecondary)"},children:["已完成章节 ",e.partialChapters.filter(e=>"completed"===e.status).length,"/",e.partialChapters.length," \xb7 ",e.partialChapters.reduce((e,t)=>e+t.chars,0).toLocaleString()," 字"]}),("warning"===e.status||"failed"===e.status||"aborted"===e.status)&&(0,l.jsx)("div",{style:{marginTop:3,color:"failed"===e.status||"aborted"===e.status?"var(--colorError)":"var(--colorWarning)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.error||(null==(r=e.warningIssues)?void 0:r[0])||(null==(n=e.draft)||null==(s=n.validationIssues.find(e=>"error"===e.level||"warning"===e.level))?void 0:s.message)||"需复核"})]}),(0,l.jsxs)(o.A,{size:4,align:"center",children:[(0,l.jsx)(i.A,{color:"completed"===(d=e.status)?"success":"warning"===d?"warning":"failed"===d?"error":"aborted"===d?"default":"processing",style:{margin:0,fontSize:10,lineHeight:"18px"},children:"completed"===(u=e.status)?"已完成":"warning"===u?"需复核":"failed"===u?"失败":"aborted"===u?"已中止":"生成中"}),(0,l.jsxs)(i.A,{style:{margin:0,fontSize:10,lineHeight:"18px"},children:["#",t+1]}),(0,l.jsx)(g.A,{title:"确认删除?",onConfirm:t=>{null==t||t.stopPropagation(),t$(e)},children:(0,l.jsx)(p.Ay,{size:"small",danger:!0,icon:(0,l.jsx)(L.A,{}),onClick:e=>e.stopPropagation()})}),tG(e.status)&&(0,l.jsx)(g.A,{title:"确定中止此生成任务?",onConfirm:t=>{null==t||t.stopPropagation(),t8(e)},children:(0,l.jsx)(p.Ay,{size:"small",danger:!0,onClick:e=>e.stopPropagation(),children:"中止"})}),("failed"===e.status||"aborted"===e.status||"warning"===e.status&&!!(null==(a=e.checkpointChapters)?void 0:a.length)&&/继续生成|重新生成|中断|卡住|未完成/u.test(e.error||(null==(c=e.warningIssues)?void 0:c.join(";"))||""))&&(0,l.jsx)(p.Ay,{size:"small",onClick:t=>{t.stopPropagation(),t6(e)},children:"继续"}),(0,l.jsx)(p.Ay,{size:"small",type:"primary",icon:tG(e.status)?(0,l.jsx)(K.A,{spin:!0}):(0,l.jsx)(O.A,{}),onClick:t=>{t.stopPropagation(),tW(e)},children:"打开"})]})]},e.id)})})}),(0,l.jsx)(f.A,{title:rr,open:tb,onClose:()=>{tS(!1),tC.current&&(clearInterval(tC.current),tC.current=null)},size:800,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:eP?(0,l.jsxs)(o.A,{wrap:!0,children:[(0,l.jsx)(p.Ay,{icon:(0,l.jsx)(V.A,{}),disabled:eJ,onClick:()=>{t3()},children:ed("documents.saveDraft")}),(0,l.jsx)(p.Ay,{icon:(0,l.jsx)(U.A,{}),disabled:eJ,loading:"markdown"===eV,onClick:()=>{t4("markdown")},children:"MD"}),(0,l.jsx)(p.Ay,{disabled:eJ,loading:"html"===eV,onClick:()=>{t4("html")},children:"HTML"}),(0,l.jsx)(p.Ay,{disabled:eJ,loading:"docx"===eV,onClick:()=>{t4("docx")},children:"DOCX"}),(0,l.jsx)(p.Ay,{type:"primary",disabled:eJ,loading:"pdf"===eV,onClick:()=>{t4("pdf")},children:"PDF"})]}):eF&&"workflow"===tk?(0,l.jsx)(p.Ay,{danger:!0,onClick:()=>{(async()=>{if(eq&&await (0,Q.r)(eq,tm||void 0).catch(()=>void 0),et){var e;et.aborted=!0,null==(e=et.pollController)||e.abort(),et.loading=!1,et.error="用户中止",er(),et=null}localStorage.removeItem(tR),tC.current&&(clearInterval(tC.current),tC.current=null),eD(!1),tg([]),tv(null),tS(!1),await tE(),eu.info("已中止生成任务")})()},children:"中止任务"}):void 0,children:(0,l.jsxs)(ee,{style:{width:"100%"},gap:16,children:["workflow"===tk&&tx.length>0&&(0,l.jsx)(ee,{gap:10,children:tx.map((e,t)=>{let r;return(0,l.jsxs)("div",{style:{display:"flex",gap:10,padding:10,border:"1px solid var(--colorBorderSecondary)",borderRadius:10,background:t===tN?"var(--colorFillAlter)":"var(--colorBgContainer)"},children:[(0,l.jsx)("span",{children:"process"===e.status?(0,l.jsx)(P.A,{}):"warning"===e.status?(0,l.jsx)(B.A,{style:{color:"var(--colorWarning)"}}):e.icon}),(0,l.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,l.jsxs)(o.A,{wrap:!0,children:[(0,l.jsx)(Z,{strong:!0,children:e.title}),(0,l.jsx)(i.A,{color:"finish"===e.status?"success":"error"===e.status?"error":"warning"===e.status?"warning":"process"===e.status?"processing":"default",children:"warning"===(r=e.status)?"finish":r})]}),(0,l.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12,whiteSpace:"pre-wrap"},children:(0,l.jsxs)("div",{children:[e.subtitle&&(0,l.jsx)("div",{style:{marginBottom:4},children:(0,l.jsx)(i.A,{children:e.subtitle})}),(0,l.jsx)("div",{children:e.description}),(0,l.jsx)("div",{style:{marginTop:4},children:e.subSteps.map(e=>{var t;return(0,l.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,l.jsx)(P.A,{}):"finish"===t?(0,l.jsx)(M.A,{}):"warning"===t?(0,l.jsx)(B.A,{style:{color:"var(--colorWarning)"}}):"error"===t?(0,l.jsx)(L.A,{}):(0,l.jsx)("span",{style:{display:"inline-block",height:6,width:6,borderRadius:"50%",background:"var(--colorTextTertiary)"}}),(0,l.jsx)("span",{children:e.title})]},e.key)})})]})})]})]},e.key)})}),"workflow"===tk&&(null==tj?void 0:tj.partialChapters)&&tj.partialChapters.length>0&&(0,l.jsx)(m.A,{size:"small",title:"章节进度",extra:(0,l.jsxs)(i.A,{color:"blue",children:[tj.partialChapters.filter(e=>"completed"===e.status).length,"/",tj.partialChapters.length]}),children:(0,l.jsx)(ee,{gap:6,style:{width:"100%"},children:tj.partialChapters.map(e=>(0,l.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:8,fontSize:12},children:[(0,l.jsx)(Z,{ellipsis:!0,style:{maxWidth:480},children:e.title}),(0,l.jsxs)(o.A,{size:6,children:[(0,l.jsx)(i.A,{color:"failed"===e.status?"error":"success",children:"failed"===e.status?"失败":"完成"}),(0,l.jsxs)(Z,{type:"secondary",children:[e.chars.toLocaleString()," 字"]})]})]},e.id))})}),"workflow"===tk&&(null==tj||null==(e=tj.reviewMetadata)?void 0:e.diagnostics)&&(0,l.jsx)($,{type:"info",title:"后台自动优化",children:"策略:".concat(tj.reviewMetadata.diagnostics.strategy.mode,";LLM 调用 ").concat(tj.reviewMetadata.diagnostics.llm.calls," 次;噪声过滤 ").concat((null==(t=tj.reviewMetadata.diagnostics.evidence)?void 0:t.filteredNoise)||0," 条;质量门禁 阻断").concat((null==(r=tj.reviewMetadata.diagnostics.quality)?void 0:r.blockingCount)||0,"/重要").concat((null==(a=tj.reviewMetadata.diagnostics.quality)?void 0:a.importantCount)||0,"/轻微").concat((null==(E=tj.reviewMetadata.diagnostics.quality)?void 0:E.minorCount)||0,";自动限流调整 ").concat(tj.reviewMetadata.diagnostics.llm.limitAdjustments," 次。审查与诊断信息仅用于系统修复,不会写入正文或导出文件。")}),"workflow"===tk&&eF&&0===tx.length&&(0,l.jsxs)("div",{style:{textAlign:"center",padding:40},children:[(0,l.jsx)(v.A,{}),(0,l.jsx)("div",{style:{marginTop:12,color:"var(--colorTextSecondary)"},children:"正在准备生成…"})]}),eP&&(0,l.jsx)("div",{ref:em,children:(0,l.jsx)(j.A,{items:[{key:"edit",label:ed("documents.edit"),children:(0,l.jsxs)(ee,{gap:16,style:{width:"100%"},children:[(0,l.jsx)(Y,{rows:28,value:eW,disabled:eJ,onSelect:e=>{var t,r,l;return e4({start:null!=(t=e.currentTarget.selectionStart)?t:0,end:null!=(l=null!=(r=e.currentTarget.selectionEnd)?r:e.currentTarget.selectionStart)?l:0})},onChange:e=>{var t,r,l;eG(e.target.value),e1(null),e6(null),e4({start:null!=(t=e.target.selectionStart)?t:0,end:null!=(l=null!=(r=e.target.selectionEnd)?r:e.target.selectionStart)?l:0})}}),(0,l.jsx)(m.A,{size:"small",style:{borderRadius:12,background:"linear-gradient(135deg, var(--colorFillAlter), var(--colorBgContainer))"},children:(0,l.jsxs)(ee,{gap:16,style:{width:"100%"},children:[(0,l.jsxs)(o.A,{align:"start",style:{width:"100%",justifyContent:"space-between"},children:[(0,l.jsxs)("div",{children:[(0,l.jsxs)(o.A,{size:6,children:[(0,l.jsx)(N.A,{style:{color:"var(--colorAccent)"}}),(0,l.jsx)(Z,{strong:!0,children:"精准修改"}),(0,l.jsx)(i.A,{color:"blue",children:"AI 辅助"})]}),(0,l.jsx)("div",{style:{marginTop:4,color:"var(--colorTextSecondary)",fontSize:12},children:"针对当前编辑内容补充更具体的要求,AI 会保留文档结构并按你的提示细化修改。"})]}),(0,l.jsxs)(p.Ay,{size:"small",icon:(0,l.jsx)(X.A,{}),onClick:()=>e9(e=>!e),disabled:0===e3.length,children:["历史版本 ",e3.length>0?e3.length:""]})]}),(0,l.jsx)($,{type:"info",title:"系统只负责识别修改范围,不改写你的提示词;选中文字后优先只改选区,没有选区时按光标所在小节/章节定位。"}),(0,l.jsx)(Y,{rows:4,value:eX,disabled:eJ,onChange:e=>{eQ(e.target.value),e1(null),e6(null)},placeholder:"例如:写细一点;润色这段;第七章补充高处作业和临电安全措施;把安全检查频次改成每周一次。"}),(0,l.jsxs)(o.A,{wrap:!0,style:{width:"100%",justifyContent:"space-between"},children:[(0,l.jsx)(o.A,{wrap:!0,children:["写细一点","更专业","只润色选区","补充可执行措施"].map(e=>(0,l.jsx)(p.Ay,{size:"small",disabled:eJ,onClick:()=>eQ(t=>t?"".concat(t,";").concat(e):e),children:e},e))}),(0,l.jsx)(p.Ay,{type:"primary",icon:(0,l.jsx)(N.A,{}),loading:eJ&&"planning"===eZ,disabled:!eX.trim()||eJ,onClick:()=>{re()},children:"识别修改范围"})]}),e0&&!e2&&(0,l.jsx)(m.A,{size:"small",style:{borderRadius:10,borderColor:"var(--colorAccent)"},children:(0,l.jsxs)(ee,{gap:8,style:{width:"100%"},children:[(0,l.jsxs)(o.A,{wrap:!0,children:[(0,l.jsx)(i.A,{color:"purple",children:e0.scope}),(0,l.jsx)(i.A,{color:"blue",children:e0.action}),(0,l.jsxs)(i.A,{color:e0.confidence>=.8?"green":"orange",children:["置信度 ",Math.round(100*e0.confidence),"%"]}),e0.targetTitle&&(0,l.jsx)(Z,{strong:!0,children:e0.targetTitle})]}),(0,l.jsx)(Z,{children:e0.summary}),(0,l.jsx)(Z,{type:"secondary",style:{fontSize:12},children:"将按你的原始提示词执行,不添加额外编辑任务。"}),(0,l.jsxs)(o.A,{children:[(0,l.jsx)(p.Ay,{type:"primary",loading:eJ&&"applying"===eZ,onClick:()=>{rt(e0)},children:"执行并预览"}),(0,l.jsx)(p.Ay,{disabled:eJ,onClick:()=>e1(null),children:"取消"})]})]})}),e2&&(0,l.jsx)(m.A,{size:"small",style:{borderRadius:10,borderColor:"var(--colorSuccess)"},children:(0,l.jsxs)(ee,{gap:8,style:{width:"100%"},children:[(0,l.jsxs)(o.A,{wrap:!0,children:[(0,l.jsx)(i.A,{color:"green",children:"修改预览"}),(0,l.jsx)(Z,{children:e2.summary||e2.plan.summary}),(0,l.jsxs)(i.A,{children:[e2.changedChars&&e2.changedChars>0?"+".concat(e2.changedChars):e2.changedChars," 字符"]})]}),(0,l.jsxs)(y.A,{gutter:12,children:[(0,l.jsxs)(w.A,{span:12,children:[(0,l.jsx)(Z,{strong:!0,children:"修改前"}),(0,l.jsx)("div",{style:{marginTop:6,maxHeight:180,overflow:"auto",padding:10,borderRadius:8,background:"var(--colorFillAlter)",whiteSpace:"pre-wrap",fontSize:12},children:e2.beforeSnippet||"无片段预览"})]}),(0,l.jsxs)(w.A,{span:12,children:[(0,l.jsx)(Z,{strong:!0,children:"修改后"}),(0,l.jsx)("div",{style:{marginTop:6,maxHeight:180,overflow:"auto",padding:10,borderRadius:8,background:"var(--colorFillAlter)",whiteSpace:"pre-wrap",fontSize:12},children:e2.afterSnippet||"无片段预览"})]})]}),(0,l.jsxs)(o.A,{children:[(0,l.jsx)(p.Ay,{type:"primary",onClick:()=>{e2&&(t5(e2.before,e2.prompt),eG(e2.markdown),t7(!0),eu.success("已应用精准修改"))},children:"应用到文档"}),(0,l.jsx)(p.Ay,{onClick:()=>e6(null),children:"返回计划"}),(0,l.jsx)(p.Ay,{danger:!0,onClick:()=>{e1(null),e6(null)},children:"放弃"})]})]})}),e7&&(0,l.jsx)("div",{style:{borderTop:"1px solid var(--colorBorderSecondary)",paddingTop:12},children:(0,l.jsx)(x.A,{size:"small",dataSource:e3,locale:{emptyText:"暂无历史版本"},renderItem:e=>(0,l.jsx)(x.A.Item,{actions:[(0,l.jsx)(p.Ay,{size:"small",disabled:eJ,onClick:()=>{t5(eW,"恢复前版本"),eG(e.content),t7(!0),eu.success("已恢复历史版本")},children:"恢复"},"restore")],children:(0,l.jsx)(x.A.Item.Meta,{title:(0,l.jsxs)(o.A,{children:[(0,l.jsx)(Z,{children:new Date(e.createdAt).toLocaleString()}),(0,l.jsx)(i.A,{children:e.prompt})]}),description:(0,l.jsx)(Z,{type:"secondary",ellipsis:!0,children:e.content.replace(/\s+/gu," ").slice(0,120)})})})})})]})})]})},{key:"chapters-facts",label:"章节与事实",children:(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[eP.chapters.length>0&&(0,l.jsxs)("div",{children:[(0,l.jsxs)(Z,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["章节 (",eP.chapters.length,")"]}),(0,l.jsx)(x.A,{size:"small",dataSource:eP.chapters,renderItem:e=>(0,l.jsx)(x.A.Item,{children:(0,l.jsx)(x.A.Item.Meta,{title:e.title,description:"证据: ".concat(e.evidence.length," \xb7 缺失: ").concat(e.missingFacts.length)})})})]}),eP.structuredFacts.length>0&&(0,l.jsxs)("div",{children:[(0,l.jsxs)(Z,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["结构化事实 (",eP.structuredFacts.length,")"]}),(0,l.jsx)(A.A,{size:"small",column:1,bordered:!0,children:eP.structuredFacts.map((e,t)=>(0,l.jsxs)(A.A.Item,{label:e.key,children:[(0,l.jsx)("span",{children:e.value}),(0,l.jsx)(i.A,{style:{marginLeft:8},children:e.confidence.toFixed(2)}),(0,l.jsx)(Z,{type:"secondary",style:{fontSize:11,marginLeft:8},children:e.sourceFile})]},t))})]})]})},{key:"sources-missing",label:"来源与缺失",children:(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,l.jsxs)("div",{children:[(0,l.jsxs)(Z,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["引用来源 (",eP.sources.length,")"]}),0===eP.sources.length?(0,l.jsx)(h.A,{description:"暂无"}):(0,l.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:eP.sources.map(e=>(0,l.jsxs)(i.A,{color:"blue",children:[e.filePath," (",e.count,")"]},e.filePath))})]}),(0,l.jsxs)("div",{children:[(0,l.jsxs)(Z,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:["缺失项 (",eP.missingItems.length,")"]}),0===eP.missingItems.length?(0,l.jsx)(h.A,{description:"无缺失"}):(0,l.jsx)(x.A,{size:"small",dataSource:eP.missingItems,renderItem:e=>(0,l.jsx)(x.A.Item,{children:e})})]})]})},{key:"validation",label:"校验 (".concat(eP.validationIssues.length,")"),children:0===eP.validationIssues.length?(0,l.jsx)(h.A,{description:"校验通过"}):(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[eP.validationIssues.map(e=>(0,l.jsxs)("div",{style:{border:"1px solid var(--colorBorderSecondary)",borderRadius:8,padding:12},children:[(0,l.jsx)(i.A,{color:"error"===e.level?"error":"warning"===e.level?"warning":"blue",children:e.level}),(0,l.jsx)("div",{style:{marginTop:6,whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-all",lineHeight:1.6},children:e.message}),e.suggestion&&(0,l.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))),eP.exportGate.checklist.length>0&&(0,l.jsxs)("div",{style:{marginTop:8},children:[(0,l.jsx)(Z,{strong:!0,style:{fontSize:13,marginBottom:8,display:"block"},children:"导出门禁"}),(0,l.jsx)(x.A,{size:"small",dataSource:eP.exportGate.checklist,renderItem:e=>(0,l.jsxs)(x.A.Item,{children:[(0,l.jsx)(Z,{style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:e.label}),(0,l.jsx)(i.A,{color:e.passed?"success":"error",children:e.passed?"PASS":"FAIL"})]})})]})]})},{key:"stages",label:"执行阶段 (".concat(eP.executionStages.length,")"),children:(0,l.jsx)(x.A,{size:"small",dataSource:eP.executionStages,renderItem:e=>(0,l.jsxs)(x.A.Item,{children:[(0,l.jsx)(x.A.Item.Meta,{avatar:el[e.type]||(0,l.jsx)(F.A,{}),title:(0,l.jsx)(Z,{title:e.roleId,style:{overflowWrap:"anywhere",wordBreak:"break-word"},children:"".concat(ei[e.type]||e.type," \xb7 ").concat(e.roleName||t_(e.roleId))}),description:(0,l.jsx)(Z,{type:"secondary",style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"},children:e.message})}),(0,l.jsx)(i.A,{color:"success"===e.status?"success":"failed"===e.status?"error":"skipped"===e.status?"default":"warning",children:e.status})]})})}]})})]})}),(0,l.jsx)(f.A,{title:ed("documents.templateEditor"),open:te,onClose:()=>tt(!1),size:860,mask:{closable:!1},styles:{body:{padding:20,overflow:"auto"},header:{borderBottom:"1px solid var(--colorBorderSecondary)"}},extra:(0,l.jsxs)(o.A,{children:[(0,l.jsx)(p.Ay,{onClick:()=>tt(!1),children:ed("common.cancel")}),(0,l.jsx)(p.Ay,{type:"primary",onClick:()=>{tQ()},children:ed("common.save")})]}),children:(0,l.jsxs)(d.A,{form:ep,layout:"vertical",requiredMark:"optional",children:[(0,l.jsxs)(y.A,{gutter:12,children:[(0,l.jsx)(d.A.Item,{name:"id",hidden:!0,children:(0,l.jsx)(n.A,{})}),(0,l.jsx)(w.A,{xs:24,md:8,children:(0,l.jsx)(d.A.Item,{name:"name",label:ed("documents.templateName"),rules:[{required:!0}],children:(0,l.jsx)(n.A,{})})}),(0,l.jsx)(w.A,{xs:24,md:8,children:(0,l.jsx)(d.A.Item,{name:"category",label:ed("documents.templateCategory"),children:(0,l.jsx)(n.A,{})})}),(0,l.jsx)(w.A,{xs:24,md:8,children:(0,l.jsx)(d.A.Item,{name:"outputTitle",label:ed("documents.outputTitle"),children:(0,l.jsx)(n.A,{})})}),(0,l.jsx)(w.A,{xs:24,md:12,children:(0,l.jsx)(d.A.Item,{name:"description",label:ed("documents.templateDescription"),children:(0,l.jsx)(n.A,{})})})]}),(0,l.jsx)(d.A.Item,{name:"projectRoleConfigId",label:ed("documents.projectRoleConfig"),rules:[{required:!0,message:ed("documents.projectRoleConfigRequired")}],children:(0,l.jsx)(b.A,{showSearch:!0,placeholder:ed("documents.projectRoleConfigRequired"),options:tM})}),(0,l.jsxs)("div",{className:"mb-6",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(Z,{strong:!0,className:"text-base text-[var(--colorText)] block mb-1",children:"项目文件绑定"}),(0,l.jsx)("div",{className:"text-xs text-[var(--colorTextSecondary)]",children:"每个文件角色可直接勾选文件或文件夹;勾选文件夹会自动绑定该文件夹下所有文件。"})]}),(0,l.jsx)(i.A,{color:"blue",bordered:!1,children:"按文件角色多选"})]}),(0,l.jsx)(n.A.Search,{allowClear:!0,placeholder:"搜索文件或文件夹",value:eT,onChange:e=>ez(e.target.value),className:"mb-4"}),eI?(0,l.jsxs)("div",{className:"text-center py-8",children:[(0,l.jsx)(v.A,{}),(0,l.jsx)("div",{className:"mt-3 text-[var(--colorTextSecondary)] text-xs",children:"正在加载知识库文件…"})]}):0===to.length?(0,l.jsx)(h.A,{image:h.A.PRESENTED_IMAGE_SIMPLE,description:ts?"当前项目角色未配置文件角色":"请先选择项目角色"}):0===td.length?(0,l.jsx)(h.A,{image:h.A.PRESENTED_IMAGE_SIMPLE,description:"暂无知识库文件"}):(()=>{let e=null==ti?void 0:ti.value,t=e?en(tc[e]||[]).filter(e=>tp.includes(e)):[],r=new Set(eo(tu));return(0,l.jsxs)("div",{className:"flex flex-col md:flex-row gap-4 border border-[var(--borderColor)] rounded-xl overflow-hidden bg-[var(--colorBg)]",children:[(0,l.jsxs)("div",{className:"w-full md:w-[240px] border-b md:border-b-0 md:border-r border-[var(--borderColor)] bg-[var(--colorBgHover)] flex flex-col",children:[(0,l.jsx)("div",{className:"p-3 border-b border-[var(--borderColor)] text-xs font-semibold uppercase tracking-wider text-[var(--colorTextTertiary)]",children:"文件角色"}),(0,l.jsx)("div",{className:"flex-1 overflow-y-auto max-h-[200px] md:max-h-[400px] p-2 space-y-1",children:to.map(t=>{let r=en(tc[t.value]||[]).filter(e=>tp.includes(e)).length,s=t.value===e;return(0,l.jsxs)("div",{onClick:()=>eE(t.value),className:"flex items-center justify-between p-2 rounded-lg cursor-pointer transition-all duration-200 ".concat(s?"bg-[var(--colorBgSelected)] text-[var(--colorAccent)] font-medium shadow-sm":"text-[var(--colorText)] hover:bg-[var(--colorBgElevated)]"),children:[(0,l.jsx)("span",{className:"truncate flex-1 mr-2 text-sm",children:t.label}),(0,l.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded-full ".concat(s?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"bg-[var(--colorFillAlter)] text-[var(--colorTextTertiary)]"),children:r})]},t.value)})})]}),(0,l.jsxs)("div",{className:"flex-1 flex flex-col bg-[var(--colorBgContainer)]",children:[(0,l.jsxs)("div",{className:"p-3 border-b border-[var(--borderColor)] flex items-center justify-between bg-[var(--colorBgHover)]",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"font-medium text-sm text-[var(--colorText)]",children:null==ti?void 0:ti.label}),(0,l.jsxs)(i.A,{color:"blue",bordered:!1,className:"m-0 text-[10px] leading-[18px]",children:["已选 ",t.length]})]}),(0,l.jsx)(p.Ay,{type:"text",size:"small",danger:!0,disabled:!e||0===t.length,onClick:()=>e&&tX(e,[]),children:"清空"})]}),e&&(0,l.jsx)(d.A.Item,{name:["fileBindingGroups",e],hidden:!0,children:(0,l.jsx)(n.A,{})}),(0,l.jsx)("div",{className:"px-4 py-2 border-b border-[var(--borderColor)] bg-blue-50/30 dark:bg-blue-900/10",children:(0,l.jsx)("div",{className:"text-xs text-[var(--colorTextSecondary)] truncate",children:t.length>0?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("span",{className:"text-blue-500 mr-1",children:"●"})," ",t.slice(0,4).map(ea).join("、")," ",t.length>4?" 等 ".concat(t.length," 个文件"):""]}):(0,l.jsx)("span",{className:"text-[var(--colorTextTertiary)]",children:"请在下方勾选要绑定的文件..."})})}),(0,l.jsx)("div",{className:"flex-1 p-3 overflow-y-auto max-h-[320px]",children:(0,l.jsx)(S.A,{checkable:!0,blockNode:!0,treeData:tu,checkedKeys:t,expandedKeys:eT.trim()?th:eB,onExpand:e=>eM(e),onCheck:(l,s)=>{if(!e)return;let n=new Set(t.filter(e=>!r.has(e)));for(let e of s.checkedNodes)e.isFolder?eo([e]).forEach(e=>n.add(e)):n.add(e.key);tX(e,Array.from(n))}})})]})]})})()]}),(0,l.jsx)(k.A,{type:"info",showIcon:!0,message:"文档规范由后台根据模板、提示词和角色绑定自动生成,无需手动维护规范包。",className:"mb-4 bg-[var(--colorBgHover)] border-0"})]})})]})}}},e=>{e.O(0,[433,576,375,787,195,455,506,651,636,593,792],()=>e(e.s=16403)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[309],{14569:e=>{e.exports={featureLabel:"style_featureLabel__XFSTX",featureValue:"style_featureValue__I_wMP",filterInput:"style_filterInput__4_Elu",filterSelect:"style_filterSelect__vUBJ9",statusCard:"style_statusCard__H7Mee",statusSummary:"style_statusSummary__7KavF",statusSummaryText:"style_statusSummaryText__Shw3j",statusClearBtn:"style_statusClearBtn__uJ9bE",statusExpandBtn:"style_statusExpandBtn__HhgIj",statusFilters:"style_statusFilters__g_LbG",filterPill:"style_filterPill__1pjFW",filterPillActive:"style_filterPillActive___UZVi",statusPanel:"style_statusPanel__9arTu",statusEmpty:"style_statusEmpty__8LWzH",timelineList:"style_timelineList__dqJrz",timelineItem:"style_timelineItem__dbuL_",timelineStatusIcon:"style_timelineStatusIcon__SkRwb",timelinePercent:"style_timelinePercent__pEyH4",timelineRow:"style_timelineRow__EDOVa",timelineTitle:"style_timelineTitle__Yujr8",timelineClose:"style_timelineClose__Byx_9",timelineDetail:"style_timelineDetail__nALei",timelineDesc:"style_timelineDesc__FMjWE",timelinePath:"style_timelinePath__C9VQI",timelineMeta:"style_timelineMeta__u_pCn",timelineMetaTag:"style_timelineMetaTag__G3jF1",timelineExpandArrow:"style_timelineExpandArrow__xIBdF",timelineExpandArrowOpen:"style_timelineExpandArrowOpen__TWWDC",fileNameCell:"style_fileNameCell__EHsnt",folderName:"style_folderName__VhLXP",folderRow:"style_folderRow__d7k9S",searchResultList:"style_searchResultList__cVKZg",searchResultItem:"style_searchResultItem__boj6D",searchResultHeader:"style_searchResultHeader__meVdJ",searchContent:"style_searchContent__XbUVk",pdfPreviewStrip:"style_pdfPreviewStrip__94_eG",drawingPreview:"style_drawingPreview__lkk_L"}},37690:(e,t,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/file-detail",function(){return l(48200)}])},45551:(e,t,l)=>{"use strict";function n(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024)),l=e/Math.pow(1024,t);return"".concat(l.toFixed(+(0!==t))," ").concat(["B","KB","MB","GB","TB"][t])}function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";if(!e||e<=0)return"en-US"===t?"Never":"从未";let l=Math.floor(Math.floor((Date.now()-e)/1e3)/60),n=Math.floor(l/60),a=Math.floor(n/24);return a>30?new Date(e).toLocaleDateString(t):"en-US"===t?a>0?"".concat(a,"d ago"):n>0?"".concat(n,"h ago"):l>0?"".concat(l,"m ago"):"Just now":a>0?"".concat(a," 天前"):n>0?"".concat(n," 小时前"):l>0?"".concat(l," 分钟前"):"刚刚"}l.d(t,{Jm:()=>s,fw:()=>a,z3:()=>n});let r={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},i={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function s(e){var t;let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===l?i:r)[e])?t:e}},48200:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>M});var n=l(65321),a=l(97109),r=l(1873),i=l.n(r),s=l(86109),o=l(35292),c=l(76506),d=l(33442),u=l(11702),h=l(9137),m=l(21289),g=l(68787),p=l(56985),x=l(49604),y=l(88762),_=l(85493),f=l(84253),w=l(85114),j=l(58569),A=l(7576),k=l(47210),C=l(6578),v=l(48321),S=l(45551),P=l(14569),b=l.n(P);let{Paragraph:I}=o.A;function N(e){if(!e)return{};try{return JSON.parse(e)}catch(e){return{}}}function R(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e).slice(0,30):[]}function z(e,t){let l=t.trim()?[t.trim(),...t.split(/[\s,,。;;::、]+/u)].filter(Boolean).sort((e,t)=>t.length-e.length):[];if(0===l.length)return e;let a=RegExp("(".concat(l.map(e=>e.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")).join("|"),")"),"giu");return e.split(a).map((e,t)=>l.some(t=>t.toLowerCase()===e.toLowerCase())?(0,n.jsx)("mark",{children:e},t):e)}function D(e,t,l){return null==t||""===t||Array.isArray(t)&&0===t.length?null:(0,n.jsx)(c.A.Item,{label:e,children:Array.isArray(t)?(0,n.jsx)(d.A,{wrap:!0,children:t.map(e=>(0,n.jsx)(u.A,{className:"cursor-pointer",onClick:()=>null==l?void 0:l(String(e)),children:String(e)},String(e)))}):String(t)})}function O(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"value";return e.map((e,l)=>({key:"".concat(t,"-").concat(l),name:e}))}function M(){var e,t,l,r,o;let P=(0,v.Vr)(),M=(0,s.useRouter)(),L="string"==typeof M.query.relativePath?M.query.relativePath:"",[T,E]=(0,a.useState)(),[F,B]=(0,a.useState)(!1),[J,K]=(0,a.useState)(""),[V,H]=(0,a.useState)(!1),[U,W]=(0,a.useState)(""),[X,G]=(0,a.useState)([]);(0,a.useEffect)(()=>{L&&(B(!0),K(""),(0,C.xC)(L).then(E).catch(e=>{E(void 0),K(e instanceof Error?e.message:"文件详情加载失败")}).finally(()=>B(!1)))},[L]);let $=(0,a.useMemo)(()=>(function(e){let t=N(null==e?void 0:e.file.metadataJson);return"object"==typeof t.extraction&&t.extraction?t.extraction:t})(T),[T]),q=R($.layerNames);(0,a.useEffect)(()=>{G(q)},[null==T?void 0:T.file.relativePath,q.join("|")]);let Z=U.trim().toLowerCase(),Q=(0,a.useMemo)(()=>{var e;return T&&Z?T.chunks.filter(e=>{let t=N(e.metadataJson);return[e.content,e.sectionTitle,t.rowRange,t.chunkKind,t.parentId,JSON.stringify(t)].some(e=>String(null!=e?e:"").toLowerCase().includes(Z))}):null!=(e=null==T?void 0:T.chunks)?e:[]},[T,Z]),Y=(0,a.useMemo)(()=>{var e;return T&&Z?T.parents.filter(e=>[e.content,e.sectionTitle,e.parentId,e.metadataJson].some(e=>String(null!=e?e:"").toLowerCase().includes(Z))):null!=(e=null==T?void 0:T.parents)?e:[]},[T,Z]),ee=async()=>{if(L){H(!0);try{let e=await (0,C.HC)(L);e.detail&&E(e.detail),h.Ay.success("文件索引已重建")}finally{H(!1)}}},et=async e=>{e&&(await navigator.clipboard.writeText(e),h.Ay.success("已复制"))},el=async e=>{L&&(await (0,C.tn)(L,e),h.Ay.success("file"===e?"已请求打开文件":"已请求打开目录"))},en=(0,a.useMemo)(()=>{var e,t,l,a,r,s;let o=[],h=R($.sheetNames),y=R($.columnNames),_=R($.layerNames),f=R($.blockNames),w=R($.entityTypes),j=R($.productNames),A=R($.materialNames),k=R($.entityNames),C=R($.dataPaths),v=h.length>0||y.length>0||null!=$.rowCount||null!=$.columnCount||null!=$.formulaCount||null!=$.mergeCount,S=O(y,"column"),P=(null!=(e=null==T?void 0:T.chunks)?e:[]).map(e=>N(e.metadataJson).rowRange).filter(e=>"string"==typeof e).map((e,t)=>({key:"row-".concat(t),name:e})),z=(null!=(t=null==T?void 0:T.chunks)?t:[]).flatMap(e=>e.content.split(/\r?\n/u)).map(e=>e.trim()).filter(e=>e.includes("|")).slice(0,80).map((e,t)=>({key:"grid-".concat(t),cells:e.split("|").map(e=>e.trim()).filter(Boolean)}));(v||S.length>0||P.length>0||z.length>0)&&o.push({key:"table",label:"表格",children:(0,n.jsxs)(d.A,{direction:"vertical",className:"w-full",children:[v&&(0,n.jsxs)(c.A,{size:"small",column:2,bordered:!0,children:[D("Sheet",h,W),D("表头",y,W),D("行数",$.rowCount),D("列数",$.columnCount),D("公式数",$.formulaCount),D("合并单元格",$.mergeCount)]}),S.length>0&&(0,n.jsx)(m.A,{size:"small",pagination:!1,rowKey:"key",dataSource:S,columns:[{title:"列名",dataIndex:"name",render:e=>(0,n.jsx)(u.A,{className:"cursor-pointer",onClick:()=>W(String(e)),children:String(e)})}]}),P.length>0&&(0,n.jsx)(m.A,{size:"small",pagination:!1,rowKey:"key",dataSource:P,columns:[{title:"行范围",dataIndex:"name",render:e=>(0,n.jsxs)(u.A,{color:"gold",className:"cursor-pointer",onClick:()=>W(String(e)),children:["行 ",String(e)]})}]}),z.length>0&&(0,n.jsx)(m.A,{size:"small",rowKey:"key",dataSource:z,pagination:{pageSize:10},columns:[{title:"表格网格预览",dataIndex:"cells",render:e=>(0,n.jsx)(d.A,{wrap:!0,children:e.map((e,t)=>(0,n.jsx)(u.A,{children:e},"".concat(e,"-").concat(t)))})}]})]})});let M=_.length>0||f.length>0||w.length>0||j.length>0||A.length>0||k.length>0,L=[...O(_,"layer").map(e=>({...e,type:"图层"})),...O(w,"entity").map(e=>({...e,type:"实体类型"})),...O(f,"block").map(e=>({...e,type:"块/符号"}))];(M||_.length>0||L.length>0)&&o.push({key:"drawing",label:"图纸",children:(0,n.jsxs)(d.A,{direction:"vertical",className:"w-full",children:[M&&(0,n.jsxs)(c.A,{size:"small",column:2,bordered:!0,children:[D("图层",_,W),D("块/符号",f,W),D("实体类型",w,W),D("产品/零件",j,W),D("材料",A,W),D("实体名称",k,W)]}),_.length>0&&(0,n.jsxs)(g.A,{size:"small",title:"图层开关 / 图纸预览",children:[(0,n.jsx)(p.A.Group,{value:X,options:_.map(e=>({label:e,value:e})),onChange:e=>G(e.map(String))}),(0,n.jsx)("div",{className:b().drawingPreview,children:X.map(e=>(0,n.jsx)(u.A,{color:"blue",children:e},e))})]}),L.length>0&&(0,n.jsx)(m.A,{size:"small",pagination:!1,rowKey:"key",dataSource:L,columns:[{title:"类型",dataIndex:"type",width:120},{title:"名称",dataIndex:"name",render:e=>(0,n.jsx)(u.A,{className:"cursor-pointer",onClick:()=>W(String(e)),children:String(e)})}]})]})});let E=(null!=(l=null==T?void 0:T.chunks)?l:[]).flatMap(e=>e.content.split(/\r?\n/u)).map(e=>e.trim()).filter(e=>/^[\w.[\]-]+\s*[:=]/u.test(e)).slice(0,200).map((e,t)=>{var l,n,a,r;let i=/^([^:=]+)\s*[:=]\s*(.*)$/u.exec(e);return{key:"data-".concat(t),path:null!=(a=null==i||null==(l=i[1])?void 0:l.trim())?a:e,value:null!=(r=null==i||null==(n=i[2])?void 0:n.trim())?r:""}});(C.length>0||E.length>0)&&o.push({key:"data",label:"数据路径",children:(0,n.jsxs)(d.A,{direction:"vertical",className:"w-full",children:[C.length>0&&(0,n.jsx)(x.A,{defaultExpandAll:!0,treeData:function(e){let t=new Map;for(let l of e){let e=t;for(let t of l.replace(/\[(\d+)\]/gu,".$1").split(".").filter(Boolean))e.has(t)||e.set(t,new Map),e=e.get(t)}let l=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return[...e.entries()].map(e=>{let[n,a]=e;return{title:n,key:t?"".concat(t,".").concat(n):n,children:l(a,t?"".concat(t,".").concat(n):n)}})};return l(t)}(C),onSelect:e=>{var t;return W(String(null!=(t=e[0])?t:""))}}),E.length>0&&(0,n.jsx)(m.A,{size:"small",rowKey:"key",dataSource:E,pagination:{pageSize:20},columns:[{title:"Path",dataIndex:"path",width:260,render:e=>(0,n.jsx)(u.A,{className:"cursor-pointer",onClick:()=>W(String(e)),children:String(e)})},{title:"Value",dataIndex:"value",render:e=>(0,n.jsx)("span",{className:"break-all",children:String(e)})}]})]})});let F=[$.ocrRecommended,$.ocrReason,$.ocrProvider,$.ocrLanguages,$.ocrTextLength,$.pdfPageOcrSupported,$.ocrPageCount,$.pdfOcrPageLimit,$.pdfRenderer,$.pdfPageCount,$.textPages,$.ocrAugmented,$.ocrPages,$.failedPages,$.imagePreprocessor].some(e=>null!=e),B=(null!=(a=null==T?void 0:T.chunks)?a:[]).map(e=>e.content).join("\n\n").split(/PDF OCR 第\s*(\d+)\s*页[::]/u).slice(1).reduce((e,t,l,n)=>{var a,r,i;return l%2==0&&e.push({key:"page-".concat(t),page:t,text:null!=(i=null==(r=n[l+1])||null==(a=r.split(/PDF OCR 第\s*\d+\s*页[::]/u)[0])?void 0:a.trim())?i:""}),e},[]),J=(null==T?void 0:T.file.format)==="pdf";return(F||J||B.length>0)&&o.push({key:"ocr",label:"OCR/PDF",children:(0,n.jsxs)(d.A,{direction:"vertical",className:"w-full",children:[F&&(0,n.jsxs)(c.A,{size:"small",column:2,bordered:!0,children:[D("OCR 建议",$.ocrRecommended),D("OCR 原因",$.ocrReason),D("OCR 引擎",$.ocrProvider),D("OCR 语言",$.ocrLanguages),D("OCR 文本长度",$.ocrTextLength),D("PDF 总页数",$.pdfPageCount),D("PDF 文本页数",$.textPages),D("PDF 已 OCR 增强",$.ocrAugmented),D("PDF OCR 页码",Array.isArray($.ocrPages)?$.ocrPages.join(", "):$.ocrPages),D("PDF 失败页",Array.isArray($.failedPages)?$.failedPages.map(e=>JSON.stringify(e)).join("; "):$.failedPages),D("PDF 页面 OCR 支持",$.pdfPageOcrSupported),D("PDF OCR 页数",$.ocrPageCount),D("PDF OCR 页数上限",$.pdfOcrPageLimit),D("PDF 渲染器",$.pdfRenderer),D("图像预处理",$.imagePreprocessor)]}),J&&(0,n.jsx)("div",{className:b().pdfPreviewStrip,children:Array.from({length:Math.min(Number(null!=(s=null!=(r=$.pdfPageCount)?r:$.ocrPageCount)?s:1)||1,6)},(e,t)=>(0,n.jsx)(i(),{width:220,height:320,src:"/api/kb/files/preview-pdf-page?relativePath=".concat(encodeURIComponent(T.file.relativePath),"&page=").concat(t+1),alt:"PDF 第 ".concat(t+1," 页"),unoptimized:!0},t))}),B.length>0&&(0,n.jsx)(m.A,{size:"small",rowKey:"key",dataSource:B,pagination:{pageSize:10},columns:[{title:"页码",dataIndex:"page",width:90},{title:"OCR 文本",dataIndex:"text",render:e=>(0,n.jsx)(I,{ellipsis:{rows:4,expandable:!0,symbol:"展开"},children:String(e)})}]})]})}),o},[$,T,X]),ea=[{title:"序号",key:"index",width:70,render:(e,t,l)=>l+1},{title:P("knowledge.chunkIndex"),dataIndex:"chunkIndex",width:90,render:e=>String(e)},{title:P("knowledge.chunkType"),width:110,render:(e,t)=>{var l;return(0,n.jsx)(u.A,{children:String(null!=(l=N(t.metadataJson).chunkKind)?l:t.category)})}},{title:P("knowledge.sectionOrRange"),width:220,render:(e,t)=>{let l=N(t.metadataJson),a="string"==typeof l.rowRange?l.rowRange:void 0;return(0,n.jsxs)(d.A,{wrap:!0,children:[t.sectionTitle?(0,n.jsx)(u.A,{color:"cyan",children:t.sectionTitle}):null,a?(0,n.jsxs)(u.A,{color:"gold",children:["行 ",a]}):null]})}},{title:"Token",dataIndex:"tokenCount",width:90},{title:P("knowledge.chunkContent"),render:(e,t)=>(0,n.jsx)(I,{ellipsis:{rows:3,expandable:!0,symbol:"展开"},className:b().searchContent,children:z(t.content,U)})}],er=[{title:"序号",key:"index",width:70,render:(e,t,l)=>l+1},{title:P("knowledge.parentChunkId"),dataIndex:"parentId",width:260,render:e=>(0,n.jsx)("span",{className:"break-all",children:e})},{title:"切片数",dataIndex:"chunkCount",width:90},{title:"章节",dataIndex:"sectionTitle",width:220},{title:P("knowledge.chunkContent"),render:(e,t)=>(0,n.jsx)(I,{ellipsis:{rows:3,expandable:!0,symbol:"展开"},className:b().searchContent,children:z(t.content,U)})}];return F?(0,n.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,n.jsx)(y.A,{active:!0,paragraph:{rows:1}}),(0,n.jsx)(g.A,{size:"small",children:(0,n.jsx)(y.A,{active:!0,paragraph:{rows:6}})}),(0,n.jsx)(g.A,{size:"small",children:(0,n.jsx)(y.A,{active:!0,paragraph:{rows:4}})})]}):J?(0,n.jsx)(_.A,{type:"error",showIcon:!0,message:"文件详情加载失败",description:J}):T?(0,n.jsxs)("div",{className:"space-y-5 animateFadeIn",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(w.Ay,{icon:(0,n.jsx)(k.A,{}),href:"/knowledge/files",size:"small",style:{marginBottom:12},children:"返回文件列表"}),(0,n.jsxs)("div",{className:b().searchResultHeader,children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"pageTitle",children:"文件详情"}),(0,n.jsx)("p",{className:"pageDesc",children:"查看解析结果、图纸/表格/数据结构化字段、parent chunk 和 child chunk。"})]}),(0,n.jsxs)(d.A,{children:[(0,n.jsx)(w.Ay,{onClick:()=>{et(null==T?void 0:T.absolutePath)},children:"复制原文件路径"}),(0,n.jsx)(w.Ay,{onClick:()=>{et(null==T?void 0:T.directory)},children:"复制所在目录"}),(0,n.jsx)(w.Ay,{onClick:()=>{el("file")},children:"打开文件"}),(0,n.jsx)(w.Ay,{onClick:()=>{el("directory")},children:"打开目录"}),"pdf"===T.file.format?(0,n.jsx)(w.Ay,{loading:V,onClick:()=>{ee()},children:"重新 OCR"}):null,(0,n.jsx)(w.Ay,{type:"primary",loading:V,onClick:()=>{ee()},children:"重建该文件索引"})]})]})]}),(0,n.jsx)(g.A,{size:"small",title:"基础信息",children:(0,n.jsxs)(c.A,{size:"small",column:2,bordered:!0,children:[(0,n.jsx)(c.A.Item,{label:"路径",children:T.file.relativePath}),(0,n.jsx)(c.A.Item,{label:"原文件",children:null!=(e=T.absolutePath)?e:"-"}),(0,n.jsx)(c.A.Item,{label:"所在目录",children:null!=(t=T.directory)?t:"-"}),(0,n.jsxs)(c.A.Item,{label:"分类",children:[(0,n.jsx)(u.A,{children:(0,S.Jm)(T.file.category)})," ",(0,n.jsx)(u.A,{children:T.file.format})]}),(0,n.jsx)(c.A.Item,{label:"大小",children:(0,S.z3)(T.file.fileSize)}),(0,n.jsx)(c.A.Item,{label:"切片数",children:T.file.chunkCount}),(0,n.jsx)(c.A.Item,{label:"状态",children:T.file.status}),(0,n.jsx)(c.A.Item,{label:"解析模式",children:String(null!=(l=$.extractionMode)?l:"-")}),(0,n.jsx)(c.A.Item,{label:"覆盖范围",children:String(null!=(r=$.contentCoverage)?r:"-")}),(0,n.jsx)(c.A.Item,{label:"正文长度",children:String(null!=(o=$.textLength)?o:"-")})]})}),en.length>0&&(0,n.jsx)(g.A,{size:"small",title:"结构化信息",children:(0,n.jsx)(j.A,{items:en})}),(0,n.jsx)(g.A,{size:"small",title:"详情筛选",children:(0,n.jsxs)(d.A,{direction:"vertical",className:"w-full",children:[(0,n.jsx)(A.A,{allowClear:!0,value:U,onChange:e=>W(e.target.value),placeholder:"筛选 rowRange、图层、实体、data path、section、chunk 内容"}),U?(0,n.jsxs)(d.A,{wrap:!0,children:[(0,n.jsxs)(u.A,{color:"blue",children:[P("knowledge.parentMatches")," ",Y.length]}),(0,n.jsxs)(u.A,{color:"green",children:[P("knowledge.childMatches")," ",Q.length]}),(0,n.jsxs)(u.A,{color:"purple",children:[P("knowledge.filterTerm")," ",U]})]}):null]})}),(0,n.jsxs)(g.A,{size:"small",title:"".concat(P("knowledge.parentChunks")," (").concat(Y.length,"/").concat(T.parents.length,")"),children:[(0,n.jsx)(_.A,{type:"info",showIcon:!0,message:P("knowledge.parentChunkHint"),style:{marginBottom:12}}),(0,n.jsx)(m.A,{rowKey:"id",columns:er,dataSource:Y,pagination:{pageSize:10},size:"small"})]}),(0,n.jsx)(g.A,{size:"small",title:"".concat(P("knowledge.childChunks")," (").concat(Q.length,"/").concat(T.chunks.length,")"),children:(0,n.jsx)(m.A,{rowKey:"id",columns:ea,dataSource:Q,pagination:{pageSize:20},size:"small"})})]}):(0,n.jsx)(f.A,{description:"请选择文件"})}}},e=>{e.O(0,[433,576,985,375,787,289,506,850,636,593,792],()=>e(e.s=37690)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[28],{1611:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-600 72h560v208H232V136zm560 480H232V408h560v208zm0 272H232V680h560v208zM304 240a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0zm0 272a40 40 0 1080 0 40 40 0 10-80 0z"}}]},name:"database",theme:"outlined"}},12887:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494zM504 618H320c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zM312 490v48c0 4.4 3.6 8 8 8h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H320c-4.4 0-8 3.6-8 8z"}}]},name:"file-text",theme:"outlined"}},13067:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494zM514.1 580.1l-61.8-102.4c-2.2-3.6-6.1-5.8-10.3-5.8h-38.4c-2.3 0-4.5.6-6.4 1.9-5.6 3.5-7.3 10.9-3.7 16.6l82.3 130.4-83.4 132.8a12.04 12.04 0 0010.2 18.4h34.5c4.2 0 8-2.2 10.2-5.7L510 664.8l62.3 101.4c2.2 3.6 6.1 5.7 10.2 5.7H620c2.3 0 4.5-.7 6.5-1.9 5.6-3.6 7.2-11 3.6-16.6l-84-130.4 85.3-132.5a12.04 12.04 0 00-10.1-18.5h-35.7c-4.2 0-8.1 2.2-10.3 5.8l-61.2 102.3z"}}]},name:"file-excel",theme:"outlined"}},14569:e=>{e.exports={featureLabel:"style_featureLabel__XFSTX",featureValue:"style_featureValue__I_wMP",filterInput:"style_filterInput__4_Elu",filterSelect:"style_filterSelect__vUBJ9",statusCard:"style_statusCard__H7Mee",statusSummary:"style_statusSummary__7KavF",statusSummaryText:"style_statusSummaryText__Shw3j",statusClearBtn:"style_statusClearBtn__uJ9bE",statusExpandBtn:"style_statusExpandBtn__HhgIj",statusFilters:"style_statusFilters__g_LbG",filterPill:"style_filterPill__1pjFW",filterPillActive:"style_filterPillActive___UZVi",statusPanel:"style_statusPanel__9arTu",statusEmpty:"style_statusEmpty__8LWzH",timelineList:"style_timelineList__dqJrz",timelineItem:"style_timelineItem__dbuL_",timelineStatusIcon:"style_timelineStatusIcon__SkRwb",timelinePercent:"style_timelinePercent__pEyH4",timelineRow:"style_timelineRow__EDOVa",timelineTitle:"style_timelineTitle__Yujr8",timelineClose:"style_timelineClose__Byx_9",timelineDetail:"style_timelineDetail__nALei",timelineDesc:"style_timelineDesc__FMjWE",timelinePath:"style_timelinePath__C9VQI",timelineMeta:"style_timelineMeta__u_pCn",timelineMetaTag:"style_timelineMetaTag__G3jF1",timelineExpandArrow:"style_timelineExpandArrow__xIBdF",timelineExpandArrowOpen:"style_timelineExpandArrowOpen__TWWDC",fileNameCell:"style_fileNameCell__EHsnt",folderName:"style_folderName__VhLXP",folderRow:"style_folderRow__d7k9S",searchResultList:"style_searchResultList__cVKZg",searchResultItem:"style_searchResultItem__boj6D",searchResultHeader:"style_searchResultHeader__meVdJ",searchContent:"style_searchContent__XbUVk",pdfPreviewStrip:"style_pdfPreviewStrip__94_eG",drawingPreview:"style_drawingPreview__lkk_L"}},23793:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"}}]},name:"delete",theme:"outlined"}},25258:(e,t,r)=>{"use strict";r.d(t,{A:()=>w});var a=r(51541),l=r(61848),s=r(5669),n=r(97109),i=r(72658),o=r(3638),c=r(92162),d=r(82725),u=r(74567),h=r(632),f=r(49517),m=r(79412),v=r(19527);let p=(0,d.U)(e=>{let{prefixCls:t,className:r,closeIcon:a,closable:l,type:s,title:d,children:p,footer:x,classNames:g,styles:y,...w}=e,{getPrefixCls:b}=n.useContext(u.QO),{className:j,style:_,classNames:A,styles:z}=(0,u.TP)("modal"),k=b(),C=t||b("modal"),S=(0,h.A)(k),[P,M]=(0,v.Ay)(C,S),[N,O]=(0,c.AV)([A,g],[z,y],{props:e}),T=`${C}-confirm`,H={};return H=s?{closable:l??!1,title:"",footer:"",children:n.createElement(f.k,{...e,prefixCls:C,confirmPrefixCls:T,rootPrefixCls:k,content:p})}:{closable:l??!0,title:d,footer:null!==x&&n.createElement(m.w,{...e}),children:p},n.createElement(i.Z,{prefixCls:C,className:(0,o.$)(P,`${C}-pure-panel`,s&&T,s&&`${T}-${s}`,r,j,M,S,N.root),style:{..._,...O.root},...w,closeIcon:(0,m.O)(C,a),closable:l,classNames:N,styles:O,...H})});var x=r(99739);function g(e){return(0,a.Ay)((0,a.fp)(e))}let y=s.A;y.useModal=x.A,y.info=function(e){return(0,a.Ay)((0,a.$D)(e))},y.success=function(e){return(0,a.Ay)((0,a.Ej)(e))},y.error=function(e){return(0,a.Ay)((0,a.jT)(e))},y.warning=g,y.warn=g,y.confirm=function(e){return(0,a.Ay)((0,a.lr)(e))},y.destroyAll=function(){for(;l.A.length;){let e=l.A.pop();e&&e()}},y.config=a.FB,y._InternalPanelDoNotUseOrYouWillBeFired=p;let w=y},26619:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var a=r(97109),l=r(1611),s=r(88483);function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}let i=a.forwardRef((e,t)=>a.createElement(s.A,n({},e,{ref:t,icon:l.A})))},26631:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var a=r(97109),l=r(12887),s=r(88483);function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}let i=a.forwardRef((e,t)=>a.createElement(s.A,n({},e,{ref:t,icon:l.A})))},30289:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.4 800.9c.2-.3.5-.6.7-.9C920.6 722.1 960 621.7 960 512s-39.4-210.1-104.8-288c-.2-.3-.5-.5-.7-.8-1.1-1.3-2.1-2.5-3.2-3.7-.4-.5-.8-.9-1.2-1.4l-4.1-4.7-.1-.1c-1.5-1.7-3.1-3.4-4.6-5.1l-.1-.1c-3.2-3.4-6.4-6.8-9.7-10.1l-.1-.1-4.8-4.8-.3-.3c-1.5-1.5-3-2.9-4.5-4.3-.5-.5-1-1-1.6-1.5-1-1-2-1.9-3-2.8-.3-.3-.7-.6-1-1C736.4 109.2 629.5 64 512 64s-224.4 45.2-304.3 119.2c-.3.3-.7.6-1 1-1 .9-2 1.9-3 2.9-.5.5-1 1-1.6 1.5-1.5 1.4-3 2.9-4.5 4.3l-.3.3-4.8 4.8-.1.1c-3.3 3.3-6.5 6.7-9.7 10.1l-.1.1c-1.6 1.7-3.1 3.4-4.6 5.1l-.1.1c-1.4 1.5-2.8 3.1-4.1 4.7-.4.5-.8.9-1.2 1.4-1.1 1.2-2.1 2.5-3.2 3.7-.2.3-.5.5-.7.8C103.4 301.9 64 402.3 64 512s39.4 210.1 104.8 288c.2.3.5.6.7.9l3.1 3.7c.4.5.8.9 1.2 1.4l4.1 4.7c0 .1.1.1.1.2 1.5 1.7 3 3.4 4.6 5l.1.1c3.2 3.4 6.4 6.8 9.6 10.1l.1.1c1.6 1.6 3.1 3.2 4.7 4.7l.3.3c3.3 3.3 6.7 6.5 10.1 9.6 80.1 74 187 119.2 304.5 119.2s224.4-45.2 304.3-119.2a300 300 0 0010-9.6l.3-.3c1.6-1.6 3.2-3.1 4.7-4.7l.1-.1c3.3-3.3 6.5-6.7 9.6-10.1l.1-.1c1.5-1.7 3.1-3.3 4.6-5 0-.1.1-.1.1-.2 1.4-1.5 2.8-3.1 4.1-4.7.4-.5.8-.9 1.2-1.4a99 99 0 003.3-3.7zm4.1-142.6c-13.8 32.6-32 62.8-54.2 90.2a444.07 444.07 0 00-81.5-55.9c11.6-46.9 18.8-98.4 20.7-152.6H887c-3 40.9-12.6 80.6-28.5 118.3zM887 484H743.5c-1.9-54.2-9.1-105.7-20.7-152.6 29.3-15.6 56.6-34.4 81.5-55.9A373.86 373.86 0 01887 484zM658.3 165.5c39.7 16.8 75.8 40 107.6 69.2a394.72 394.72 0 01-59.4 41.8c-15.7-45-35.8-84.1-59.2-115.4 3.7 1.4 7.4 2.9 11 4.4zm-90.6 700.6c-9.2 7.2-18.4 12.7-27.7 16.4V697a389.1 389.1 0 01115.7 26.2c-8.3 24.6-17.9 47.3-29 67.8-17.4 32.4-37.8 58.3-59 75.1zm59-633.1c11 20.6 20.7 43.3 29 67.8A389.1 389.1 0 01540 327V141.6c9.2 3.7 18.5 9.1 27.7 16.4 21.2 16.7 41.6 42.6 59 75zM540 640.9V540h147.5c-1.6 44.2-7.1 87.1-16.3 127.8l-.3 1.2A445.02 445.02 0 00540 640.9zm0-156.9V383.1c45.8-2.8 89.8-12.5 130.9-28.1l.3 1.2c9.2 40.7 14.7 83.5 16.3 127.8H540zm-56 56v100.9c-45.8 2.8-89.8 12.5-130.9 28.1l-.3-1.2c-9.2-40.7-14.7-83.5-16.3-127.8H484zm-147.5-56c1.6-44.2 7.1-87.1 16.3-127.8l.3-1.2c41.1 15.6 85 25.3 130.9 28.1V484H336.5zM484 697v185.4c-9.2-3.7-18.5-9.1-27.7-16.4-21.2-16.7-41.7-42.7-59.1-75.1-11-20.6-20.7-43.3-29-67.8 37.2-14.6 75.9-23.3 115.8-26.1zm0-370a389.1 389.1 0 01-115.7-26.2c8.3-24.6 17.9-47.3 29-67.8 17.4-32.4 37.8-58.4 59.1-75.1 9.2-7.2 18.4-12.7 27.7-16.4V327zM365.7 165.5c3.7-1.5 7.3-3 11-4.4-23.4 31.3-43.5 70.4-59.2 115.4-21-12-40.9-26-59.4-41.8 31.8-29.2 67.9-52.4 107.6-69.2zM165.5 365.7c13.8-32.6 32-62.8 54.2-90.2 24.9 21.5 52.2 40.3 81.5 55.9-11.6 46.9-18.8 98.4-20.7 152.6H137c3-40.9 12.6-80.6 28.5-118.3zM137 540h143.5c1.9 54.2 9.1 105.7 20.7 152.6a444.07 444.07 0 00-81.5 55.9A373.86 373.86 0 01137 540zm228.7 318.5c-39.7-16.8-75.8-40-107.6-69.2 18.5-15.8 38.4-29.7 59.4-41.8 15.7 45 35.8 84.1 59.2 115.4-3.7-1.4-7.4-2.9-11-4.4zm292.6 0c-3.7 1.5-7.3 3-11 4.4 23.4-31.3 43.5-70.4 59.2-115.4 21 12 40.9 26 59.4 41.8a373.81 373.81 0 01-107.6 69.2z"}}]},name:"global",theme:"outlined"}},35311:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M456 231a56 56 0 10112 0 56 56 0 10-112 0zm0 280a56 56 0 10112 0 56 56 0 10-112 0zm0 280a56 56 0 10112 0 56 56 0 10-112 0z"}}]},name:"more",theme:"outlined"}},45551:(e,t,r)=>{"use strict";function a(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024)),r=e/Math.pow(1024,t);return"".concat(r.toFixed(+(0!==t))," ").concat(["B","KB","MB","GB","TB"][t])}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";if(!e||e<=0)return"en-US"===t?"Never":"从未";let r=Math.floor(Math.floor((Date.now()-e)/1e3)/60),a=Math.floor(r/60),l=Math.floor(a/24);return l>30?new Date(e).toLocaleDateString(t):"en-US"===t?l>0?"".concat(l,"d ago"):a>0?"".concat(a,"h ago"):r>0?"".concat(r,"m ago"):"Just now":l>0?"".concat(l," 天前"):a>0?"".concat(a," 小时前"):r>0?"".concat(r," 分钟前"):"刚刚"}r.d(t,{Jm:()=>i,fw:()=>l,z3:()=>a});let s={document:"文档",spreadsheet:"表格",image:"图片",cad:"图纸",code:"代码",data:"数据",web:"网页",diagram:"图表",archive:"压缩包",other:"其他"},n={document:"Document",spreadsheet:"Spreadsheet",image:"Image",cad:"CAD",code:"Code",data:"Data",web:"Web",diagram:"Diagram",archive:"Archive",other:"Other"};function i(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"zh-CN";return null!=(t=("en-US"===r?n:s)[e])?t:e}},48893:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M553.1 509.1l-77.8 99.2-41.1-52.4a8 8 0 00-12.6 0l-99.8 127.2a7.98 7.98 0 006.3 12.9H696c6.7 0 10.4-7.7 6.3-12.9l-136.5-174a8.1 8.1 0 00-12.7 0zM360 442a40 40 0 1080 0 40 40 0 10-80 0zm494.6-153.4L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494z"}}]},name:"file-image",theme:"outlined"}},53234:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-600 72h560v208H232V136zm560 480H232V408h560v208zm0 272H232V680h560v208zM496 208H312c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zM312 544h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H312c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8zm328 244a40 40 0 1080 0 40 40 0 10-80 0z"}}]},name:"hdd",theme:"outlined"}},54746:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var a=r(97109),l=r(71242),s=r(88483);function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}let i=a.forwardRef((e,t)=>a.createElement(s.A,n({},e,{ref:t,icon:l.A})))},58209:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var a=r(97109),l=r(23793),s=r(88483);function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}let i=a.forwardRef((e,t)=>a.createElement(s.A,n({},e,{ref:t,icon:l.A})))},58520:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494zM528.1 472h-32.2c-5.5 0-10.3 3.7-11.6 9.1L434.6 680l-46.1-198.7c-1.3-5.4-6.1-9.3-11.7-9.3h-35.4a12.02 12.02 0 00-11.6 15.1l74.2 276c1.4 5.2 6.2 8.9 11.6 8.9h32c5.4 0 10.2-3.6 11.6-8.9l52.8-197 52.8 197c1.4 5.2 6.2 8.9 11.6 8.9h31.8c5.4 0 10.2-3.6 11.6-8.9l74.4-276a12.04 12.04 0 00-11.6-15.1H647c-5.6 0-10.4 3.9-11.7 9.3l-45.8 199.1-49.8-199.3c-1.3-5.4-6.1-9.1-11.6-9.1z"}}]},name:"file-word",theme:"outlined"}},61825:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var a=r(97109),l=r(30289),s=r(88483);function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}let i=a.forwardRef((e,t)=>a.createElement(s.A,n({},e,{ref:t,icon:l.A})))},64207:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>ee});var a=r(65321),l=r(97109),s=r(48321),n=r(43220),i=r.n(n),o=r(86109),c=r(17807),d=r(25258),u=r(11702),h=r(71102),f=r(85114),m=r(7576),v=r(57271),p=r(33442),x=r(21289),g=r(56768),y=r(48893),w=r(88483);function b(){return(b=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}let j=l.forwardRef((e,t)=>l.createElement(w.A,b({},e,{ref:t,icon:y.A})));var _=r(13067);function A(){return(A=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}let z=l.forwardRef((e,t)=>l.createElement(w.A,A({},e,{ref:t,icon:_.A})));var k=r(58520);function C(){return(C=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}let S=l.forwardRef((e,t)=>l.createElement(w.A,C({},e,{ref:t,icon:k.A})));var P=r(90939);function M(){return(M=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}let N=l.forwardRef((e,t)=>l.createElement(w.A,M({},e,{ref:t,icon:P.A})));var O=r(93314),T=r(61825),H=r(26619),E=r(7225),F=r(26631),V=r(64254),B=r(64629),I=r(58209),R=r(85855),D=r(30486),L=r(54746),q=r(84742),$=r(38762),J=r(39219),Q=r(22931),U=r(6578),W=r(45551),X=r(14569),G=r.n(X);let K=["document","spreadsheet","image","cad","code","data","web","diagram","other"],Z=/\.(zip|jar|war|apk|tar|gz|tgz|bz2|rar|7z)$/iu,Y=/(^|\/)\.DS_Store$|(^|\/)Thumbs\.db$|(^|\/)__MACOSX\/|\.bak$/iu;function ee(){let e=(0,s.Vr)("knowledge"),{locale:t}=(0,s.x_)(),{message:r}=c.A.useApp(),n=(0,o.useRouter)(),y="string"==typeof n.query.category?n.query.category:"",[w,b]=(0,l.useState)([]),[_,A]=(0,l.useState)(!1),[k,C]=(0,l.useState)(""),[P,M]=(0,l.useState)(""),[X,ee]=(0,l.useState)(y),[et,er]=(0,l.useState)(!1),[ea,el]=(0,l.useState)(!1),[es,en]=(0,l.useState)([]),[ei,eo]=(0,l.useState)([]),[ec,ed]=(0,l.useState)(new Set),[eu,eh]=(0,l.useState)("all"),[ef,em]=(0,l.useState)(!0),[ev,ep]=(0,l.useState)([]),[ex,eg]=(0,l.useState)(new Set),ey=(0,l.useRef)(X);(0,l.useEffect)(()=>{ey.current=X},[X]),(0,l.useEffect)(()=>{ee("string"==typeof n.query.category?n.query.category:"")},[n.query.category]);let ew=(0,l.useCallback)(async(e,t)=>{let r=null!=e?e:ey.current;(null==t?void 0:t.silent)||(A(!0),C(""));try{let e=await (0,U.HT)({category:r||void 0,limit:5e3});b(e.files||[]),e.initializing&&window.setTimeout(()=>{ew(r,{silent:!0})},3e3)}catch(e){(null==t?void 0:t.silent)||(b([]),C(e instanceof Error?e.message:"文件列表加载失败"))}finally{(null==t?void 0:t.silent)||A(!1)}},[]);(0,l.useEffect)(()=>{ew(X)},[X,ew]);let eb=e=>({id:e.id,type:e.type,title:e.title,description:e.message,status:e.status,percent:e.percent,filePath:e.filePath,chunkCount:e.chunkCount,textLength:e.textLength,extractionMode:e.extractionMode,error:e.error,createdAt:e.createdAt}),ej=(0,l.useCallback)(async()=>{try{let e=(await (0,U.Qx)()).operations.map(eb);en(t=>{let r=new Set(e.map(e=>e.id).filter(Boolean)),a=e.map(e=>{var r;let a=t.find(t=>t.id===e.id);return a?{...a,...e,createdAt:null!=(r=a.createdAt)?r:e.createdAt}:e}),l=t.filter(e=>e.id&&!r.has(e.id)&&"processing"===e.status);return[...a,...l].slice(0,50)})}catch(e){}},[]),e_=(0,l.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];en(r=>{let a=r.findIndex(r=>e.id&&r.id===e.id||t.includes(r.title));if(a>=0){var l;let t=[...r];return t[a]={...r[a],...e,createdAt:null!=(l=r[a].createdAt)?l:e.createdAt},t}return[e,...r].slice(0,50)})},[]);(0,l.useEffect)(()=>{ej()},[ej]);let eA=(0,l.useMemo)(()=>{let e=0,t=0,r=0;for(let a of es)"processing"===a.status?e++:"success"===a.status?t++:("error"===a.status||"warning"===a.status)&&r++;return{processing:e,success:t,error:r}},[es]);(0,l.useEffect)(()=>{eA.processing>0&&em(!1)},[eA.processing]),(0,l.useEffect)(()=>{if(0===eA.processing)return;let e=window.setInterval(()=>{ej()},2e3),t=window.setInterval(()=>{ew(void 0,{silent:!0})},8e3);return()=>{window.clearInterval(e),window.clearInterval(t)}},[ew,ej,eA.processing]),"all"===eu||es.filter(e=>"processing"===eu?"processing"===e.status:"success"===eu?"success"===e.status:"error"!==eu||"error"===e.status||"warning"===e.status);let ez=async e=>{let t=e.filter(e=>{let t=e.webkitRelativePath||e.name;return e.size>0&&!Z.test(e.name)&&!Y.test(t)}),a=e.length-t.length;if(a>0&&r.warning("已跳过 ".concat(a," 个空文件、系统文件、备份文件或压缩包")),0===t.length)return;let l=1===t.length?t[0].name:"".concat(t.length," 个文件");er(!0);let s="".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2));e_({id:s,type:"upload",title:"上传 ".concat(l),description:"等待上传、解析、切片和入库;同路径文件会更新,其他已有文件不会清除",status:"processing",percent:5});try{await (0,U.c1)(t,void 0,s,e=>{e_({id:s,type:"upload",title:"上传 ".concat(l),description:"正在上传文件:".concat(e.uploadedFiles,"/").concat(e.totalFiles,",批次 ").concat(e.batchIndex+1,"/").concat(e.totalBatches),status:"processing",percent:Math.min(5,Math.max(1,Math.round(e.uploadedFiles/Math.max(1,e.totalFiles)*5)))})}),r.info("文件已上传,正在后台解析、切片和入库;同路径文件会更新,其他已有文件不会清除,可在顶部“后台任务”查看进度"),M(""),ee(""),eo([]),ey.current="",await ej(),window.setTimeout(()=>{ew(void 0,{silent:!0})},2e3)}catch(t){let e=t instanceof Error?t.message:"请重试或检查文件格式";r.error(e||"上传失败"),e_({id:s,type:"error",title:"上传失败 ".concat(l),description:e,status:"error",percent:100})}finally{er(!1)}},ek=async()=>{el(!0);let e="reindex-ui-".concat(Date.now());e_({id:e,type:"reindex",title:"重新解析入库",description:"正在提交后台任务",status:"processing",percent:5});try{var t;let a=await (0,U.H1)(),l=a.operationId||e,s=a.job;r.info(a.alreadyRunning?"已有重新解析任务正在后台执行":"已提交重新解析入库任务,可在顶部“后台任务”查看进度"),e_({id:l,type:"reindex",title:(null==s?void 0:s.title)||"重新解析入库",description:(null==s?void 0:s.message)||"后台将重新扫描文件、解析、切片并重建索引",status:(null==s?void 0:s.status)||"processing",percent:null!=(t=null==s?void 0:s.percent)?t:10,error:null==s?void 0:s.error},["重新解析入库"]);for(let e=0;e<360;e++){let e=await (0,U.ax)(l).then(e=>e.job).catch(async()=>(await (0,U.Qx)()).operations.find(e=>e.id===l));if(e){let t="success"===e.status||"error"===e.status;if(e_({id:l,type:"error"===e.status?"error":"reindex",title:"success"===e.status?"重新解析入库完成":"error"===e.status?"重新解析入库失败":e.title,description:e.error||e.message,status:e.status,percent:e.percent,filePath:e.filePath,chunkCount:e.chunkCount,error:e.error}),t){"success"===e.status?r.success(e.message||"重新解析入库完成"):r.error(e.error||e.message||"重新解析入库失败");break}}await new Promise(e=>setTimeout(e,1e3))}await ew(),await ej()}catch(a){let t=a instanceof Error?a.message:"重新解析入库失败";r.error(t),e_({id:e,type:"error",title:"重新解析入库失败",description:t,status:"error",percent:100},["重新解析入库","重新解析入库完成","重新解析入库失败"])}finally{el(!1)}},eC=async e=>{let t="file-reindex-ui-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2));eg(t=>new Set(t).add(e.relativePath)),e_({id:t,type:"reindex",title:"重新解析 ".concat(e.relativePath),description:"正在提交单文件后台任务",status:"processing",percent:5,filePath:e.relativePath});try{var a;let l=await (0,U.HC)(e.relativePath),s=l.operationId||t,n=l.job;r.info(l.alreadyRunning?"已有知识库任务正在后台执行":"已提交单文件重新解析任务"),e_({id:s,type:"reindex",title:(null==n?void 0:n.title)||"重新解析 ".concat(e.relativePath),description:(null==n?void 0:n.message)||"后台将重新解析、分块并入库该文件",status:(null==n?void 0:n.status)||"processing",percent:null!=(a=null==n?void 0:n.percent)?a:10,filePath:(null==n?void 0:n.filePath)||e.relativePath,chunkCount:null==n?void 0:n.chunkCount,error:null==n?void 0:n.error},["重新解析 ".concat(e.relativePath)]);for(let t=0;t<240;t++){let t=await (0,U.ax)(s).then(e=>e.job).catch(async()=>(await (0,U.Qx)()).operations.find(e=>e.id===s));if(t){let a="success"===t.status||"error"===t.status;if(e_({id:s,type:"error"===t.status?"error":"reindex",title:"success"===t.status?"重新解析完成 ".concat(e.relativePath):"error"===t.status?"重新解析失败 ".concat(e.relativePath):t.title,description:t.error||t.message,status:t.status,percent:t.percent,filePath:t.filePath||e.relativePath,chunkCount:t.chunkCount,error:t.error}),await ew(),a){"success"===t.status?r.success(t.message||"单文件重新解析完成"):r.error(t.error||t.message||"单文件重新解析失败");break}}await new Promise(e=>setTimeout(e,1e3))}await ew(),await ej()}catch(l){let a=l instanceof Error?l.message:"单文件重新解析失败";r.error(a),e_({id:t,type:"error",title:"重新解析失败 ".concat(e.relativePath),description:a,status:"error",percent:100,filePath:e.relativePath},["重新解析 ".concat(e.relativePath)])}finally{eg(t=>{let r=new Set(t);return r.delete(e.relativePath),r})}},eS=t=>{let a="selected"===t?eF:"filtered"===t?eP.map(e=>e.relativePath):[],l=w.length;if("all"!==t&&0===a.length||"all"===t&&0===l)return void r.info("没有可删除的文件");let s="all"===t?"删除全部文件 ".concat(l," 个?"):"filtered"===t?"删除当前筛选结果中的文件 ".concat(a.length," 个?"):"删除已选文件 ".concat(a.length," 个?");d.A.confirm({title:s,content:"将同时删除文件、切片、索引和向量记录。此操作不可撤销。",okText:e("common.delete"),cancelText:e("common.cancel"),okButtonProps:{danger:!0},onOk:async()=>{en(e=>[{type:"delete",title:s,description:"正在批量删除文件和索引",status:"processing",percent:10},...e].slice(0,50));try{var e;let s=null!=(e=("all"===t?await (0,U.X8)():"selected"===t?await (0,U.tZ)(eE,eH):await (0,U.SJ)(a)).deleted)?e:"all"===t?l:a.length;r.success("已删除 ".concat(s," 个文件")),eo([]),en(e=>[{type:"delete",title:"批量删除完成",description:"已删除 ".concat(s," 个文件、切片和索引"),status:"success"},...e].slice(0,50)),await ew(),await ej()}catch(e){r.error("批量删除失败"),en(e=>[{type:"error",title:"批量删除失败",description:"请重试",status:"error"},...e].slice(0,50))}}})},eP=(0,l.useMemo)(()=>P?w.filter(e=>e.relativePath.toLowerCase().includes(P.toLowerCase())):w,[P,w]),eM=(0,l.useMemo)(()=>new Set(eP.map(e=>e.relativePath)),[eP]),eN=(0,l.useMemo)(()=>{let e={};for(let r of[...eP].sort((e,t)=>e.relativePath.localeCompare(t.relativePath))){let a=r.relativePath.split("/"),l="";for(let s=0;s<a.length;s++){let n=a[s],i=l;l=l?"".concat(l,"/").concat(n):n;let o=s===a.length-1;if(e[l])o||e[l].isFolder?o&&(e[l].isFolder=!1,e[l].file=r,e[l].fileCount=1,e[l].totalSize=r.fileSize,e[l].totalChunks=r.chunkCount):(e[l].isFolder=!0,e[l].children=[],e[l].fileCount=0,e[l].totalSize=0,e[l].totalChunks=0);else{var t;e[l]={key:l,name:n,isFolder:!o,...o?{file:r,fileCount:1,totalSize:r.fileSize,totalChunks:r.chunkCount}:{children:[],fileCount:0,totalSize:0,totalChunks:0}},i&&(null==(t=e[i])?void 0:t.children)&&e[i].children.push(e[l])}}}let r=e=>{for(let s of e)if(s.children){r(s.children);let e=0,n=0,i=0;for(let r of s.children){var t,a,l;e+=null!=(t=r.fileCount)?t:0,n+=null!=(a=r.totalSize)?a:0,i+=null!=(l=r.totalChunks)?l:0}s.fileCount=e,s.totalSize=n,s.totalChunks=i}},a=e=>e.map(e=>e.children?{...e,children:a(e.children)}:e).filter(e=>{var t,r,a;return!e.isFolder||(null!=(r=e.fileCount)?r:0)>0&&(null!=(a=null==(t=e.children)?void 0:t.length)?a:0)>0}),l=Object.values(e).filter(e=>!e.key.includes("/"));return r(l),a(l)},[eP]),eO=(0,l.useMemo)(()=>{let e=[],t=r=>{for(let a of r)e.push(a.key),a.children&&t(a.children)};return t(eN),e},[eN]),eT=(0,l.useMemo)(()=>new Set([...eM,...eO]),[eO,eM]),eH=(0,l.useMemo)(()=>ei.map(String).filter(e=>!eM.has(e)&&eO.includes(e)),[eO,ei,eM]),eE=(0,l.useMemo)(()=>ei.map(String).filter(e=>eM.has(e)),[ei,eM]),eF=(0,l.useMemo)(()=>{let e=new Set;for(let t of eE){let r=w.find(e=>e.relativePath===t);r&&e.add(r.relativePath)}for(let t of eH){let r="".concat(t,"/");for(let t of w)t.relativePath.startsWith(r)&&e.add(t.relativePath)}return Array.from(e)},[w,eE,eH]),eV=eF.length;(0,l.useEffect)(()=>{eo(e=>e.filter(e=>eT.has(String(e))))},[eT]);let eB=(0,l.useMemo)(()=>P?eO:[],[P,eO]);(0,l.useEffect)(()=>{ep(eB)},[eB]);let eI=(e,t)=>{ep(r=>e?[...r,t.key]:r.filter(e=>e!==t.key))},eR=[{title:e("fileName"),dataIndex:"name",key:"name",render:(e,t)=>(0,a.jsxs)("span",{className:G().fileNameCell,children:[t.isFolder?(0,a.jsx)("span",{style:{cursor:"pointer"},onClick:e=>{e.stopPropagation(),eI(!ev.includes(t.key),t)},children:(e=>{let t=e.children;return t&&0!==t.length?(0,a.jsx)(V.A,{style:{color:"#fa8c16",fontSize:15}}):(0,a.jsx)(E.A,{style:{color:"#fa8c16",fontSize:15}})})(t)}):(e=>{if(!e)return(0,a.jsx)(g.A,{style:{fontSize:15}});let t=e.category;return"image"===t?(0,a.jsx)(j,{style:{color:"#eb2f96",fontSize:15}}):"spreadsheet"===t?(0,a.jsx)(z,{style:{color:"#52c41a",fontSize:15}}):"document"===t?(0,a.jsx)(S,{style:{color:"#1677ff",fontSize:15}}):"code"===t?(0,a.jsx)(N,{style:{color:"#fa8c16",fontSize:15}}):"archive"===t?(0,a.jsx)(O.A,{style:{color:"#8c8c8c",fontSize:15}}):"web"===t?(0,a.jsx)(T.A,{style:{color:"#13c2c2",fontSize:15}}):"data"===t?(0,a.jsx)(H.A,{style:{color:"#722ed1",fontSize:15}}):"cad"===t?(0,a.jsx)(E.A,{style:{color:"#fa541c",fontSize:15}}):"diagram"===t?(0,a.jsx)(j,{style:{color:"#a0d911",fontSize:15}}):(0,a.jsx)(F.A,{style:{fontSize:15}})})(t.file),t.isFolder?(0,a.jsx)("span",{className:G().folderName,onClick:e=>{e.stopPropagation(),eI(!ev.includes(t.key),t)},children:t.name}):(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(i(),{className:"min-w-0 max-w-[520px] whitespace-normal break-words leading-relaxed",href:"/knowledge/file-detail?relativePath=".concat(encodeURIComponent(t.key)),children:t.name})})]})},{title:e("fileCategory"),dataIndex:"category",key:"cat",width:110,render:(e,r)=>{var l,s;return r.isFolder?(0,a.jsx)("span",{style:{color:"var(--colorTextQuaternary)"},children:"—"}):(0,a.jsx)(u.A,{children:(0,W.Jm)(null!=(s=null==(l=r.file)?void 0:l.category)?s:"",t)})}},{title:e("fileSize"),dataIndex:"fileSize",key:"size",width:90,render:(e,t)=>{var r,a,l;return(0,W.z3)(t.isFolder?null!=(a=t.totalSize)?a:0:null!=(l=null==(r=t.file)?void 0:r.fileSize)?l:0)}},{title:e("chunksCount"),dataIndex:"chunkCount",key:"chunks",width:80,render:(e,t)=>{var r,l,s;let n=t.isFolder?null!=(l=t.totalChunks)?l:0:null!=(s=null==(r=t.file)?void 0:r.chunkCount)?s:0;return(0,a.jsx)(u.A,{color:n>1?"green":"orange",children:n})}},{title:e("parsingStatus"),dataIndex:"status",key:"status",width:100,render:(e,t)=>{var r,l,s,n;return t.isFolder?(0,a.jsx)("span",{style:{color:"var(--colorTextQuaternary)"},children:"—"}):(0,a.jsx)(u.A,{color:"active"===(n=null==(r=t.file)?void 0:r.status)?"green":"processing"===n||"indexing"===n?"blue":"error"===n?"red":"orange",children:(null==(l=t.file)?void 0:l.errorMessage)||(null==(s=t.file)?void 0:s.status)||"—"})}},{title:e("fileDate"),dataIndex:"mtime",key:"date",width:130,render:(e,r)=>{var l;return r.isFolder?(0,a.jsx)("span",{style:{color:"var(--colorTextQuaternary)"},children:"—"}):(null==(l=r.file)?void 0:l.mtime)?new Date(r.file.mtime).toLocaleDateString(t):"—"}},{title:e("source"),key:"source",width:100,render:(t,r)=>r.isFolder?(0,a.jsx)("span",{style:{color:"var(--colorTextQuaternary)"},children:"—"}):(0,a.jsx)(u.A,{color:"cyan",children:e("fileSource")})},{title:"",key:"act",width:80,align:"center",render:(t,l)=>l.isFolder?null:(0,a.jsx)(h.A,{menu:{items:[{key:"reindex",label:e("reindex"),icon:(0,a.jsx)(B.A,{}),onClick:()=>{eC(l.file)}},{type:"divider"},{key:"delete",label:e("delete"),icon:(0,a.jsx)(I.A,{}),danger:!0,onClick:()=>{var t;return t=l.file,void d.A.confirm({title:e("delete"),content:e("deleteConfirm"),okText:e("common.confirm"),cancelText:e("common.cancel"),okButtonProps:{danger:!0},onOk:async()=>{en(e=>[{type:"delete",title:"删除 ".concat(t.relativePath),description:"正在删除文件记录",status:"processing"},...e].slice(0,50));try{await (0,U.xq)(t.relativePath),r.success("已删除"),en(e=>[{type:"delete",title:"删除完成 ".concat(t.relativePath),description:"文件和索引记录已移除",status:"success"},...e].slice(0,50)),eo(e=>e.filter(e=>e!==t.relativePath)),await ew(),await ej()}catch(e){r.error("删除失败"),en(e=>[{type:"error",title:"删除失败 ".concat(t.relativePath),description:"请重试",status:"error"},...e].slice(0,50))}}})}}]},trigger:["click"],children:(0,a.jsx)(f.Ay,{type:"text",size:"small",icon:(0,a.jsx)(R.A,{})})})}],eD=(0,a.jsxs)("div",{className:"flex flex-1 md:flex-none w-full md:w-auto items-center gap-3",children:[(0,a.jsx)(m.A,{placeholder:e("searchPlaceholder"),prefix:(0,a.jsx)(D.A,{className:"text-[var(--colorTextTertiary)]"}),value:P,onChange:e=>{M(e.target.value)},allowClear:!0,className:"max-w-[300px] flex-1 bg-transparent hover:bg-transparent focus:bg-transparent shadow-none",bordered:!1,style:{borderBottom:"1px solid var(--borderColor)",borderRadius:0,paddingLeft:0,paddingRight:0}}),(0,a.jsx)(v.A,{value:X||void 0,onChange:e=>{ee(e||"")},placeholder:e("filterCategory"),allowClear:!0,style:{width:140},variant:"borderless",options:[{label:e("allCategories"),value:""},...K.map(e=>({label:(0,W.Jm)(e,t),value:e}))]}),(0,a.jsx)("div",{className:"w-[1px] h-6 bg-[var(--borderColor)] mx-1"}),(0,a.jsx)(h.A,{menu:{items:[{key:"file",label:e("uploadFiles"),icon:(0,a.jsx)(g.A,{}),onClick:()=>{var e;return null==(e=document.getElementById("kb-file-upload-input"))?void 0:e.click()}},{key:"folder",label:e("uploadFolder"),icon:(0,a.jsx)(E.A,{}),onClick:()=>{var e;return null==(e=document.getElementById("kb-folder-upload-input"))?void 0:e.click()}},{type:"divider"},{key:"reindex",label:e("reindexAll"),icon:(0,a.jsx)(B.A,{}),onClick:()=>{ek()},danger:!0}]},trigger:["click"],children:(0,a.jsx)(f.Ay,{type:"primary",icon:(0,a.jsx)(L.A,{}),loading:et||ea,className:"shadow-none rounded-md px-4",children:e("new")})}),(0,a.jsx)("input",{id:"kb-file-upload-input",type:"file",multiple:!0,hidden:!0,accept:".pdf,.doc,.docx,.txt,.md,.csv,.tsv,.xls,.xlsx,.png,.jpg,.jpeg,.webp,.svg,.dwg,.dxf,.step,.stp,.iges,.igs,.js,.ts,.tsx,.jsx,.py,.go,.java,.cs,.cpp,.c,.h,.json,.jsonl,.yaml,.yml,.xml,.html,.htm,.drawio,.dio,.vsdx,.vdx,.puml,.plantuml,.mmd,.mermaid,.excalidraw",onChange:e=>{var t;let r=Array.from(null!=(t=e.target.files)?t:[]);e.target.value="",ez(r)}}),(0,a.jsx)("input",{id:"kb-folder-upload-input",type:"file",multiple:!0,hidden:!0,webkitdirectory:"",onChange:e=>{var t;let r=Array.from(null!=(t=e.target.files)?t:[]);e.target.value="",ez(r)}})]});return(0,a.jsxs)("div",{className:"h-[calc(100vh-140px)] flex flex-col",children:[(0,a.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 pb-4 border-b border-[var(--borderColor)] shrink-0 animateFadeIn",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-2xl font-bold tracking-tight text-[var(--colorText)] mb-1",children:e("files")}),(0,a.jsx)("p",{className:"text-xs text-[var(--colorTextSecondary)]",children:e("manageRawFiles")})]}),eD]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 py-4 shrink-0 animateFadeIn stagger-1 border-b border-[var(--borderColor)] mb-2",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2 border-r border-[var(--borderColor)] pr-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--colorBgHover)] flex items-center justify-center text-[var(--colorTextTertiary)]",children:(0,a.jsx)(V.A,{})}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wider font-semibold text-[var(--colorTextTertiary)]",children:e("totalRootFolders")})]}),(0,a.jsx)("div",{className:"text-2xl font-bold text-[var(--colorText)]",children:eN.length}),(0,a.jsx)("div",{className:"text-xs text-[var(--colorTextSecondary)] mt-1",children:"目录层级"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 border-r border-[var(--borderColor)] px-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--colorBgHover)] flex items-center justify-center text-[var(--colorTextTertiary)]",children:(0,a.jsx)(F.A,{})}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wider font-semibold text-[var(--colorTextTertiary)]",children:e("totalFilesStats")})]}),(0,a.jsx)("div",{className:"text-2xl font-bold text-[var(--colorText)]",children:w.length}),(0,a.jsxs)("div",{className:"text-xs text-[var(--colorTextSecondary)] mt-1",children:["包含 ",w.filter(e=>"PDF"===e.category).length," 个 PDF"]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 border-r border-[var(--borderColor)] px-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--colorOk)]/10 flex items-center justify-center text-[var(--colorOk)]",children:(0,a.jsx)(q.A,{})}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wider font-semibold text-[var(--colorTextTertiary)]",children:e("successfullyParsed")})]}),(0,a.jsx)("div",{className:"text-2xl font-bold text-[var(--colorOk)]",children:w.filter(e=>"success"===e.status).length}),(0,a.jsxs)("div",{className:"text-xs text-[var(--colorTextSecondary)] mt-1",children:["总计切片: ",w.reduce((e,t)=>e+(t.chunkCount||0),0)]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 pl-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"w-6 h-6 rounded-md bg-[var(--colorDanger)]/10 flex items-center justify-center text-[var(--colorDanger)]",children:(0,a.jsx)($.A,{})}),(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wider font-semibold text-[var(--colorTextTertiary)]",children:e("parsingErrors")})]}),(0,a.jsx)("div",{className:"text-2xl font-bold text-[var(--colorDanger)]",children:w.filter(e=>"error"===e.status).length}),(0,a.jsx)("div",{className:"text-xs text-[var(--colorTextSecondary)] mt-1",children:"需手动排查"})]})]}),k&&(0,a.jsx)("div",{className:"p-4 mt-2 bg-[var(--colorDanger)]/10 text-[var(--colorDanger)] rounded-md border border-[var(--colorDanger)]/20",children:k}),(0,a.jsxs)("div",{className:"flex justify-between items-center py-2 shrink-0 animateFadeIn stagger-2",style:{opacity:0},children:[(0,a.jsx)("div",{className:"text-xs text-[var(--colorTextSecondary)] font-medium",children:e("showingMatchingFiles").replace("{count}",String(eP.length))}),(0,a.jsxs)(p.A,{size:8,children:[eV>0&&(0,a.jsxs)(f.Ay,{danger:!0,size:"small",type:"text",icon:(0,a.jsx)(I.A,{}),onClick:()=>eS("selected"),children:[e("deleteSelected")," (",eV,")"]}),(0,a.jsx)(f.Ay,{danger:!0,size:"small",type:"text",disabled:0===w.length,onClick:()=>eS("all"),children:e("deleteAll")})]})]}),(0,a.jsx)("div",{className:"flex-1 min-h-0 bg-[var(--colorBg)] rounded-lg animateFadeIn stagger-3",style:{opacity:0},children:(0,a.jsx)(x.A,{rowKey:"key",columns:eR,dataSource:eN,loading:_&&!et&&!ea,size:"middle",className:"h-full modern-table",scroll:{y:"calc(100vh - 280px)"},expandable:{expandedRowKeys:ev,onExpand:eI,expandIcon:e=>{let{expanded:t,onExpand:r,record:l}=e;return l.isFolder?(0,a.jsx)("button",{type:"button",onClick:e=>r(l,e),className:"w-6 h-6 mr-1 inline-flex items-center justify-center align-middle text-[var(--colorTextTertiary)] hover:text-[var(--colorText)] transition-colors bg-transparent border-0 p-0 leading-none",children:t?(0,a.jsx)(J.A,{size:16}):(0,a.jsx)(Q.A,{size:16})}):(0,a.jsx)("span",{className:"w-6 h-6 inline-flex"})}},locale:{emptyText:_?e("common.loading"):P?e("emptySearch"):e("noFiles")},pagination:!1,rowClassName:e=>"hover:bg-[var(--colorBgHover)] transition-colors ".concat(e.isFolder?"font-medium bg-[var(--colorBgSecondary)]/50":""),rowSelection:{selectedRowKeys:ei,onChange:eo,checkStrictly:!1,getCheckboxProps:e=>{var t;return{disabled:!!e.isFolder&&(null!=(t=e.fileCount)?t:0)===0}}}})})]})}},71242:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z"}},{tag:"path",attrs:{d:"M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8z"}}]},name:"plus",theme:"outlined"}},85855:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var a=r(97109),l=r(35311),s=r(88483);function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}let i=a.forwardRef((e,t)=>a.createElement(s.A,n({},e,{ref:t,icon:l.A})))},90426:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/knowledge/files",function(){return r(64207)}])},90939:(e,t)=>{"use strict";t.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M516 673c0 4.4 3.4 8 7.5 8h185c4.1 0 7.5-3.6 7.5-8v-48c0-4.4-3.4-8-7.5-8h-185c-4.1 0-7.5 3.6-7.5 8v48zm-194.9 6.1l192-161c3.8-3.2 3.8-9.1 0-12.3l-192-160.9A7.95 7.95 0 00308 351v62.7c0 2.4 1 4.6 2.9 6.1L420.7 512l-109.8 92.2a8.1 8.1 0 00-2.9 6.1V673c0 6.8 7.9 10.5 13.1 6.1zM880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"}}]},name:"code",theme:"outlined"}},93314:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var a=r(97109),l=r(53234),s=r(88483);function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}let i=a.forwardRef((e,t)=>a.createElement(s.A,n({},e,{ref:t,icon:l.A})))}},e=>{e.O(0,[433,576,985,375,289,636,593,792],()=>e(e.s=90426)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46],{77305:(e,r,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/models",function(){return a(82744)}])},82744:(e,r,a)=>{"use strict";a.r(r),a.d(r,{default:()=>R});var l=a(65321),s=a(97109),o=a(48321),t=a(35292),c=a(33442);let{Title:i,Text:n}=t.A;function d(e){let{title:r,description:a,extra:s,bottomContent:o}=e;return(0,l.jsxs)("div",{className:"mb-6 animateFadeIn",children:[(0,l.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end justify-between gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(i,{level:4,style:{margin:0,fontWeight:700,letterSpacing:"-0.01em"},children:r}),a&&(0,l.jsx)(n,{type:"secondary",className:"mt-1 block text-sm",children:a})]}),s&&(0,l.jsx)(c.A,{className:"w-full sm:w-auto overflow-x-auto pb-1 sm:pb-0",size:"middle",wrap:!1,children:s})]}),o&&(0,l.jsx)("div",{className:"mt-4",children:o})]})}var m=a(17807),x=a(88762),p=a(85114),v=a(26171),h=a(11702),b=a(57271),u=a(7576),g=a(48318),j=a(34052),y=a(63455),f=a(56985),N=a(44534),A=a(54746),w=a(29071),k=a(59188),C=a(4216),T=a(13114),S=a(99650),B=a(58209),P=a(76981),E=a(61825),I=a(6578);let K=[{label:"OpenAI 兼容",value:"openai"},{label:"Anthropic",value:"anthropic"},{label:"Google",value:"google"},{label:"Ollama",value:"ollama"},{label:"OpenRouter",value:"openrouter"}],H=[{key:"reader",labelKey:"models.tierReader",descKey:"models.tierReaderDesc"},{key:"reasoning",labelKey:"models.tierReasoning",descKey:"models.tierReasoningDesc"},{key:"action",labelKey:"models.tierAction",descKey:"models.tierActionDesc"}],U=[{key:"imageGeneration",label:"图片生成"},{key:"imageUnderstanding",label:"图片理解"},{key:"fileUnderstanding",label:"文件理解"},{key:"audio",label:"音频能力"},{key:"video",label:"视频能力"}],_={enabled:!1,allowProjectFacts:!1,maxQueriesPerChapter:2,maxResultsPerQuery:3,trustedDomains:[]};function R(){let e=(0,o.Vr)(),{message:r}=m.A.useApp(),[a,t]=(0,s.useState)(!0),[i,n]=(0,s.useState)([]),[R,z]=(0,s.useState)(null),[F,D]=(0,s.useState)({provider:"transformers-local",model:"BAAI/bge-small-zh-v1.5",dimensions:512}),[O,L]=(0,s.useState)(_),[M,G]=(0,s.useState)(!1),[Q,q]=(0,s.useState)(!1),[X,Z]=(0,s.useState)(!1),[V,W]=(0,s.useState)(null),[J,Y]=(0,s.useState)(null),[$,ee]=(0,s.useState)({}),[er,ea]=(0,s.useState)(!1),[el,es]=(0,s.useState)(!1),[eo,et]=(0,s.useState)(""),[ec,ei]=(0,s.useState)(""),[en,ed]=(0,s.useState)(""),[em,ex]=(0,s.useState)(""),[ep,ev]=(0,s.useState)("openai"),[eh,eb]=(0,s.useState)(!1),[eu,eg]=(0,s.useState)({}),[ej,ey]=(0,s.useState)(!1),[ef,eN]=(0,s.useState)(!1),eA=async()=>{t(!0);try{let[e,r,a,l]=await Promise.all([(0,I.Z3)().catch(()=>[]),(0,I.zr)().catch(()=>null),(0,I.II)().catch(()=>({provider:"transformers-local",model:"BAAI/bge-small-zh-v1.5",dimensions:512})),(0,I.jQ)().catch(()=>_)]);n(e),z(r),D(a),L(l)}catch(a){r.error(e("common.error"))}finally{t(!1)}};(0,s.useEffect)(()=>{eA()},[]);let ew=async e=>{var r,a;es(!0),et(e.name),ei(e.name),ed(""),ex(e.baseUrl||""),ev(e.protocol||e.detectedProtocol||"openai"),eg(e.capabilities||{}),ey(!!(null==(r=e.capabilities)?void 0:r.webSearch));try{let r=await (0,I.Bh)(e.name);ed(r.apiKey?"••••••••":""),ex(r.baseUrl||""),eg(r.capabilities||{}),ey(!!(null==(a=r.capabilities)?void 0:a.webSearch))}catch(e){}ea(!0)},ek=async()=>{if(ec.trim()){eN(!0);try{let a=el&&en.includes("•")?void 0:en||void 0,l={...eu,webSearch:ej};await (0,I._m)(ec.trim(),{oldName:el?eo:void 0,apiKey:a,baseUrl:em||void 0,protocol:ep,directEndpoint:eh,capabilities:l}),ea(!1),await eA(),r.success(e("common.success"))}catch(a){r.error(e("common.error"))}finally{eN(!1)}}},eC=async a=>{try{await (0,I.h1)(a),await eA(),r.success(e("common.success"))}catch(a){r.error(e("common.error"))}},eT=async a=>{Y(a);try{let l=await (0,I.bZ)(a);ee(e=>({...e,[a]:l.success}));let s=l.success?e("models.connected"):"".concat(e("models.connectionFailed")).concat(l.message?":".concat(l.message):"").concat(l.requestId?" (".concat(l.requestId,")"):"");r[l.success?"success":"error"](s)}catch(l){ee(e=>({...e,[a]:!1})),r.error(l instanceof Error?l.message:e("models.connectionFailed"))}finally{Y(null)}},eS=async(a,l)=>{if(!R)return;let s={...R},o=s[a];if(!l){o.active="",z(s);try{await (0,I.aP)(s)}catch(a){r.error(e("common.error"))}return}let[t,c]=l.includes(":")?l.split(":"):[l,l];o.active=c,o.list.some(e=>e.name===c&&e.provider===t)||o.list.push({name:c,provider:t}),z(s);try{await (0,I.aP)(s)}catch(a){r.error(e("common.error"))}},eB=async()=>{q(!0);try{let a=await (0,I.dd)(F);D(a),W(null),r.success(e("common.success"))}catch(a){r.error(e("common.error"))}finally{q(!1)}},eP=async()=>{Z(!0);try{let a=await (0,I.u6)();W(a.success),r[a.success?"success":"error"](a.message||(a.success?e("models.connected"):e("models.connectionFailed")))}catch(e){W(!1)}finally{Z(!1)}};return a?(0,l.jsxs)("div",{className:"space-y-6",children:[(0,l.jsx)(x.A,{active:!0,title:!0,paragraph:{rows:1}}),(0,l.jsx)("div",{className:"p-4 bg-[var(--colorBgHover)] rounded-xl border border-[var(--borderColor)]",children:(0,l.jsx)(x.A,{active:!0,paragraph:{rows:6}})}),(0,l.jsx)("div",{className:"p-4 bg-[var(--colorBgHover)] rounded-xl border border-[var(--borderColor)]",children:(0,l.jsx)(x.A,{active:!0,paragraph:{rows:4}})}),(0,l.jsx)("div",{className:"p-4 bg-[var(--colorBgHover)] rounded-xl border border-[var(--borderColor)]",children:(0,l.jsx)(x.A,{active:!0,paragraph:{rows:3}})})]}):(0,l.jsxs)("div",{className:"space-y-6",children:[(0,l.jsx)(d,{title:e("models.title"),description:e("models.description"),extra:(0,l.jsx)(p.Ay,{type:"primary",icon:(0,l.jsx)(A.A,{}),onClick:()=>{es(!1),et(""),ei(""),ed(""),ex(""),ev("openai"),eb(!1),eg({}),ey(!1),ea(!0)},children:e("models.addModel")})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"flex items-center justify-between mb-6",children:(0,l.jsxs)("h2",{className:"text-base font-semibold text-[var(--colorText)] tracking-wide",children:[e("models.modelList")," ",(0,l.jsxs)("span",{className:"text-[var(--colorTextTertiary)] ml-2 font-normal",children:["(",i.length,")"]})]})}),0===i.length?(0,l.jsx)("div",{className:"text-center py-12 bg-[var(--colorBgHover)] rounded-2xl border border-dashed border-[var(--borderColorStrong)] text-[var(--colorTextTertiary)] text-sm",children:e("models.noProviders")}):(0,l.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:i.map(r=>{var a;return(0,l.jsxs)("div",{className:"group p-5 rounded-2xl border border-transparent hover:border-[var(--borderColorStrong)] bg-[var(--colorBgContainer)] hover:bg-[var(--colorBgHover)] hover:shadow-sm flex flex-col cursor-pointer transition-all duration-300",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 mb-4 min-w-0",children:[(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsx)("div",{className:"font-bold text-base text-[var(--colorText)] truncate mb-1",children:r.name}),(0,l.jsxs)("div",{className:"text-xs text-[var(--colorTextTertiary)] flex items-center gap-1 uppercase tracking-wider font-semibold",children:[(0,l.jsx)(w.A,{})," ",r.protocol||r.detectedProtocol||"openai"]})]}),(0,l.jsxs)(c.A,{size:0,className:"-mr-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,l.jsx)(p.Ay,{type:"text",size:"small",loading:J===r.name,onClick:e=>{e.stopPropagation(),eT(r.name)},icon:!0===$[r.name]?(0,l.jsx)(k.A,{className:"text-[var(--colorOk)]"}):!1===$[r.name]?(0,l.jsx)(C.A,{className:"text-[var(--colorDanger)]"}):(0,l.jsx)(T.A,{className:"text-[var(--colorTextSecondary)]"})}),(0,l.jsx)(p.Ay,{type:"text",size:"small",icon:(0,l.jsx)(S.A,{className:"text-[var(--colorTextSecondary)]"}),onClick:e=>{e.stopPropagation(),ew(r)}}),(0,l.jsx)(v.A,{title:e("models.deleteProviderConfirm"),onConfirm:e=>{null==e||e.stopPropagation(),eC(r.name)},onCancel:e=>null==e?void 0:e.stopPropagation(),children:(0,l.jsx)(p.Ay,{type:"text",size:"small",danger:!0,icon:(0,l.jsx)(B.A,{}),onClick:e=>e.stopPropagation()})})]})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-3 mt-auto pt-4 border-t border-[var(--borderColor)]",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between text-xs text-[var(--colorTextSecondary)]",children:[(0,l.jsxs)("span",{className:"flex items-center gap-1",children:[(0,l.jsx)(P.A,{})," API Key"]}),(0,l.jsx)("span",{className:"font-mono text-[var(--colorTextTertiary)]",children:r.hasApiKey?"••••••••":"None"})]}),r.baseUrl&&(0,l.jsxs)("div",{className:"flex items-center justify-between text-xs text-[var(--colorTextSecondary)]",children:[(0,l.jsxs)("span",{className:"flex items-center gap-1",children:[(0,l.jsx)(E.A,{})," URL"]}),(0,l.jsx)("span",{className:"truncate max-w-[120px] font-mono text-[var(--colorTextTertiary)]",title:r.baseUrl,children:r.baseUrl.replace(/^https?:\/\//,"")})]}),(0,l.jsxs)("div",{className:"flex flex-wrap gap-1 mt-2",children:[U.filter(e=>{var a;return null==(a=r.capabilities)?void 0:a[e.key]}).map(e=>(0,l.jsx)(h.A,{color:"blue",bordered:!1,className:"m-0 text-[10px] bg-[var(--colorBrand)]/5 text-[var(--colorBrand)] leading-[18px]",children:e.label},e.key)),(null==(a=r.capabilities)?void 0:a.webSearch)&&(0,l.jsx)(h.A,{color:"green",bordered:!1,className:"m-0 text-[10px] leading-[18px]",children:"联网增强"})]})]})]},r.name)})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{className:"text-base font-semibold text-[var(--colorText)] tracking-wide mb-6",children:e("models.embeddingConfig")}),(0,l.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wider mb-2 text-[var(--colorTextTertiary)]",children:e("models.embeddingProvider")}),(0,l.jsx)(b.A,{value:F.provider,className:"w-full h-10",variant:"borderless",style:{background:"var(--colorBgHover)",borderRadius:"8px"},options:[{label:"Local (Recommended)",value:"transformers-local"},{label:"External (Advanced)",value:"openai-compatible"}],onChange:e=>D(r=>({...r,provider:e,model:"transformers-local"===e?r.model||"BAAI/bge-small-zh-v1.5":r.model,dimensions:"transformers-local"===e?512:r.dimensions||1024}))})]}),"openai-compatible"===F.provider&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wider mb-2 text-[var(--colorTextTertiary)]",children:"Base URL"}),(0,l.jsx)(u.A,{className:"h-10 px-4 bg-[var(--colorBgHover)]",value:F.baseUrl,onChange:e=>D(r=>({...r,baseUrl:e.target.value})),placeholder:"http://localhost:11434/v1"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wider mb-2 text-[var(--colorTextTertiary)]",children:e("models.model")}),(0,l.jsx)(u.A,{className:"h-10 px-4 bg-[var(--colorBgHover)]",value:F.model,onChange:e=>D(r=>({...r,model:e.target.value})),placeholder:"bge-m3"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wider mb-2 text-[var(--colorTextTertiary)]",children:e("models.apiKey")}),(0,l.jsx)(u.A.Password,{className:"h-10 px-4 bg-[var(--colorBgHover)]",value:F.apiKey,onFocus:()=>{var e;(null==(e=F.apiKey)?void 0:e.includes("•"))&&D(e=>({...e,apiKey:""}))},onChange:e=>D(r=>({...r,apiKey:e.target.value})),placeholder:e("models.optional")})]})]}),"transformers-local"===F.provider&&(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wider mb-2 text-[var(--colorTextTertiary)]",children:e("models.model")}),(0,l.jsx)(u.A,{className:"h-10 px-4 bg-[var(--colorBgHover)]",value:F.model,onChange:e=>D(r=>({...r,model:e.target.value})),placeholder:"BAAI/bge-small-zh-v1.5"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wider mb-2 text-[var(--colorTextTertiary)]",children:e("models.dimensions")}),(0,l.jsx)(g.A,{className:"w-full h-10 px-2 bg-[var(--colorBgHover)] border-transparent flex items-center",min:1,value:F.dimensions,onChange:e=>D(r=>({...r,dimensions:Number(e||("transformers-local"===r.provider?512:1024))}))})]})]}),(0,l.jsxs)("div",{className:"mt-8 flex gap-3",children:[(0,l.jsx)(p.Ay,{type:"primary",className:"h-10 px-6 font-medium shadow-none",loading:Q,onClick:()=>{eB()},children:e("models.saveEmbedding")}),(0,l.jsx)(p.Ay,{className:"h-10 px-6 font-medium shadow-none bg-[var(--colorBgHover)] border-transparent hover:border-[var(--borderColorStrong)]",loading:X,onClick:()=>{eP()},children:e("models.testEmbedding")}),(0,l.jsxs)("div",{className:"ml-auto flex items-center h-10 gap-2",children:[(0,l.jsx)(h.A,{color:"blue",bordered:!1,className:"m-0 bg-[var(--colorBgHover)] text-[var(--colorTextSecondary)]",children:"transformers-local"===F.provider?"Local Embedding":e("models.openAICompatible")}),!0===V&&(0,l.jsx)(h.A,{color:"success",bordered:!1,className:"m-0",icon:(0,l.jsx)(k.A,{}),children:e("models.connected")}),!1===V&&(0,l.jsx)(h.A,{color:"error",bordered:!1,className:"m-0",icon:(0,l.jsx)(C.A,{}),children:e("models.connectionFailed")})]})]})]}),R&&(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)("div",{className:"mb-6",children:[(0,l.jsx)("h2",{className:"text-base font-semibold text-[var(--colorText)] tracking-wide mb-6",children:e("models.modelTiers")}),(0,l.jsx)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:H.map(r=>{let{key:a,labelKey:s,descKey:o}=r,t=R[a],c=t.list.map(e=>({label:"".concat(e.provider," / ").concat(e.name),value:"".concat(e.provider,":").concat(e.name)})),n=i.filter(e=>!t.list.some(r=>r.provider===e.name)).map(e=>({label:e.name,value:"".concat(e.name,":").concat(e.name)})),d=t.active?t.list.find(e=>e.name===t.active):null;return(0,l.jsxs)("div",{className:"p-6 bg-[var(--colorBgHover)] rounded-xl flex flex-col transition-colors border border-transparent hover:border-[var(--borderColorStrong)]",children:[(0,l.jsx)("div",{className:"text-sm font-semibold text-[var(--colorText)] uppercase tracking-wider mb-2",children:e(s)}),(0,l.jsx)("div",{className:"text-xs text-[var(--colorTextTertiary)] mb-5 leading-relaxed flex-1",children:e(o)}),(0,l.jsx)(b.A,{value:t.active?"".concat((null==d?void 0:d.provider)||"",":").concat(t.active):void 0,onChange:e=>{eS(a,e)},allowClear:!0,placeholder:e("models.selectModelPlaceholder"),className:"w-full h-10",variant:"borderless",style:{background:"var(--colorBgElevated)",borderRadius:"8px"},options:[...c,...n]}),d&&(()=>{let e=i.find(e=>e.name===d.provider);return(0,l.jsxs)("div",{className:"mt-4 px-4 py-3 bg-[var(--colorBgElevated)] rounded-lg border border-[var(--borderColor)] flex items-center gap-3 transition-colors",children:[(0,l.jsx)(T.A,{className:"text-[var(--colorBrand)] text-base shrink-0"}),(0,l.jsx)("span",{className:"text-sm font-medium flex-1 min-w-0 truncate text-[var(--colorText)]",children:d.provider}),(null==e?void 0:e.capabilities)&&U.filter(r=>e.capabilities[r.key]).length>0&&(0,l.jsx)("div",{className:"flex gap-1 shrink-0",children:U.filter(r=>e.capabilities[r.key]).slice(0,2).map(e=>(0,l.jsx)(h.A,{color:"blue",bordered:!1,className:"m-0 text-[10px] bg-[var(--colorBrand)]/5 text-[var(--colorBrand)] leading-[18px]",children:e.label},e.key))}),(0,l.jsx)(h.A,{color:"success",bordered:!1,className:"m-0 text-[10px] leading-[18px] shrink-0 uppercase",children:"Active"})]})})()]},a)})})]})}),(0,l.jsx)(j.A,{title:el?e("models.editModel"):e("models.addModel"),open:er,onClose:()=>ea(!1),width:800,styles:{body:{padding:"24px 32px"},header:{padding:"16px 32px",borderBottom:"1px solid var(--colorBorderSecondary)"}},extra:(0,l.jsx)(p.Ay,{type:"primary",loading:ef,onClick:()=>{ek()},children:e("common.save")}),children:(0,l.jsxs)(y.A,{layout:"vertical",children:[(0,l.jsx)(y.A.Item,{label:e("models.modelName"),children:(0,l.jsx)(u.A,{value:ec,onChange:e=>ei(e.target.value),placeholder:e("models.modelNamePlaceholder")})}),(0,l.jsx)(y.A.Item,{label:e("models.apiKey"),help:el?e("models.apiKeyEditHint"):void 0,children:(0,l.jsx)(u.A.Password,{value:en,onFocus:()=>{el&&en.includes("•")&&ed("")},onChange:e=>ed(e.target.value),placeholder:el?e("models.apiKeyEditPlaceholder"):"sk-..."})}),(0,l.jsx)(y.A.Item,{label:e("models.baseUrl"),children:(0,l.jsx)(u.A,{value:em,onChange:e=>ex(e.target.value),placeholder:"https://api.openai.com/v1"})}),(0,l.jsx)(y.A.Item,{label:e("models.protocol"),children:(0,l.jsx)(b.A,{value:ep,onChange:ev,options:K})}),(0,l.jsx)(y.A.Item,{label:e("models.directEndpoint"),children:(0,l.jsx)(f.A,{checked:eh,onChange:e=>eb(e.target.checked),children:e("models.directEndpointDesc")})}),(0,l.jsxs)(y.A.Item,{label:e("models.webEnhancement"),children:[(0,l.jsx)(N.A,{checked:ej,onChange:ey}),(0,l.jsx)("span",{className:"ml-3 text-xs text-[var(--colorTextSecondary)]",children:e("models.webEnhancementDesc")})]}),(0,l.jsx)(y.A.Item,{label:e("models.capabilities"),children:(0,l.jsx)(f.A.Group,{value:U.filter(e=>eu[e.key]).map(e=>e.key),options:U.map(e=>({label:e.label,value:e.key})),onChange:e=>eg(Object.fromEntries(U.map(r=>[r.key,e.includes(r.key)])))})})]})})]})}}},e=>{e.O(0,[576,985,195,455,337,636,593,792],()=>e(e.s=77305)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[26],{27549:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/prompt",function(){return r(34508)}])},34508:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>q});var o=r(65321),l=r(97109),a=r(48321),s=r(17807),n=r(33442),c=r(11702),i=r(56985),d=r(85114),p=r(26171),m=r(88762),x=r(7576),h=r(57271),u=r(49292),g=r(84253),v=r(34052),y=r(42700),j=r(55122),f=r(54746),b=r(99650),w=r(81668),S=r(58209),A=r(26631),N=r(7225),C=r(96091),k=r(30486),T=r(46082),z=r(42758),P=r(24810),F=r(7492);async function B(){let e=await fetch("/api/prompt");if(!e.ok)throw Error("Failed");return e.json()}async function E(e,t,r){let o=await fetch("/api/prompt",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({filePath:e,content:t,name:r})});if(!o.ok)throw Error("Failed");return o.json()}async function O(e){let t=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"create",projectRoot:e,content:"# CUSTOMIZE\n"})});if(!t.ok)throw Error("Failed");return t.json()}async function R(e,t){let r=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"createCustom",name:e,content:t})});if(!r.ok)throw Error("Failed");return r.json()}async function I(e){let t=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"select",selectedIds:e})});if(!t.ok)throw Error("Failed");return t.json()}async function H(e){let t=await fetch("/api/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"import",...e&&"object"==typeof e?e:{prompts:[]}})});if(!t.ok)throw Error(await t.text());return t.json()}async function _(){return M("",!1,60)}async function D(e){let t=await fetch("/api/kb/files/detail?relativePath=".concat(encodeURIComponent(e)));if(!t.ok)throw Error("Failed");return((await t.json()).chunks||[]).map(e=>e.content||"").filter(Boolean).join("\n\n").slice(0,12e3)}async function M(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30,o=new URLSearchParams({limit:String(r)});e.trim()&&o.set("q",e.trim()),t||o.set("includeContent","0");let l=await fetch("/api/kb/files/search?".concat(o));return l.ok&&(await l.json()).files||[]}async function J(e){let t=await fetch("/api/prompt/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.text();try{let t=JSON.parse(e);throw Error(t.error||t.message||e||"AI 对话失败")}catch(t){throw Error(e||"AI 对话失败")}}return t.json()}function L(e,t){let r=new Blob([JSON.stringify(t,null,2)],{type:"application/json;charset=utf-8"}),o=URL.createObjectURL(r),l=document.createElement("a");l.href=o,l.download=e,l.click(),URL.revokeObjectURL(o)}function W(e){return e.id.startsWith("custom:")}function K(e){return W(e)?"custom":e.isCurrent?"current":"project"}function U(e,t,r){return e?"customize-agent:prompt-chat:".concat(e.id,":").concat(e.customizePath||e.projectName):"customize-agent:prompt-chat:draft:".concat(r||t||"new")}function $(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:220,r=e.hasFile&&e.content?e.content.replace(/^#.*$/gm,"").replace(/\n{3,}/g,"\n\n").trim():"";return r.length>t?"".concat(r.slice(0,t),"..."):r}function G(e){let t=Date.parse(e);return Number.isNaN(t)?"-":new Date(t).toLocaleString()}function X(e){return{type:"customize-agent.prompts",version:1,exportedAt:new Date().toISOString(),prompts:e.map(e=>({name:e.projectName,content:e.content||"",selected:e.selected,source:K(e)}))}}function Y(e){let t=e.match(/(^|\s)@([^\s@]*)$/);return t?t[2]:null}function q(){let e=(0,a.Vr)(),{message:t}=s.A.useApp(),[r,q]=(0,l.useState)(!0),[Q,V]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(!1),[et,er]=(0,l.useState)(null),[eo,el]=(0,l.useState)(""),[ea,es]=(0,l.useState)(""),[en,ec]=(0,l.useState)(!1),[ei,ed]=(0,l.useState)(!1),[ep,em]=(0,l.useState)("custom"),[ex,eh]=(0,l.useState)("all"),[eu,eg]=(0,l.useState)("mtime"),[ev,ey]=(0,l.useState)("list"),[ej,ef]=(0,l.useState)(""),[eb,ew]=(0,l.useState)(null),[eS,eA]=(0,l.useState)([]),[eN,eC]=(0,l.useState)(!1),[ek,eT]=(0,l.useState)([]),[ez,eP]=(0,l.useState)(""),[eF,eB]=(0,l.useState)(""),[eE,eO]=(0,l.useState)(!1),[eR,eI]=(0,l.useState)([]),[eH,e_]=(0,l.useState)([]),[eD,eM]=(0,l.useState)([]),[eJ,eL]=(0,l.useState)(!1),[eW,eK]=(0,l.useState)(!1),[eU,e$]=(0,l.useState)(!1),eG=(0,l.useRef)(null),eX=(0,l.useRef)(null),eY=Y(eF),eq=async()=>{q(!0);try{V(await B())}catch(r){t.error(e("common.error"))}finally{q(!1)}};(0,l.useEffect)(()=>{eq()},[]),(0,l.useEffect)(()=>{let e=window.localStorage.getItem("customize-agent:prompt-view-mode");("list"===e||"card"===e)&&ey(e)},[]),(0,l.useEffect)(()=>{window.localStorage.setItem("customize-agent:prompt-view-mode",ev)},[ev]),(0,l.useEffect)(()=>{let e=eX.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),ez&&window.localStorage.setItem(ez,JSON.stringify(ek.slice(-30)))},[ek,eE,ez]),(0,l.useEffect)(()=>{!Z||eR.length>0||eJ||(eL(!0),_().then(eI).catch(()=>void 0).finally(()=>eL(!1)))},[Z,eR.length,eJ]),(0,l.useEffect)(()=>{let e=null==eY?void 0:eY.trim();if(!Z||!e){e_([]),eK(!1);return}let t=!1;eK(!0);let r=window.setTimeout(()=>{M(e).then(e=>{t||e_(e)}).catch(()=>{t||e_([])}).finally(()=>{t||eK(!1)})},250);return()=>{t=!0,window.clearTimeout(r)}},[Z,eY]);let eQ=Q.find(e=>e.isCurrent),eV=Q.filter(W),eZ={all:Q.length,custom:Q.filter(e=>"custom"===K(e)).length,current:Q.filter(e=>"current"===K(e)).length,project:Q.filter(e=>"project"===K(e)).length,selected:Q.filter(e=>e.selected).length,unselected:Q.filter(e=>!e.selected).length,hasFile:Q.filter(e=>e.hasFile).length,missingFile:Q.filter(e=>!e.hasFile).length},e0=Q.filter(e=>{var t;let r=K(e);return("all"===ep||r===ep)&&("selected"!==ex||!!e.selected)&&("unselected"!==ex||!e.selected)&&("hasFile"!==ex||!!e.hasFile)&&("missingFile"!==ex||!e.hasFile)&&(!ej.trim()||(t=ej.trim(),!!"".concat(e.projectName,"\n").concat(e.projectRoot||"","\n").concat(e.customizePath||"","\n").concat(e.content||"").toLowerCase().includes(t.toLowerCase())))}).sort((e,t)=>"name"===eu?e.projectName.localeCompare(t.projectName):"source"===eu?["custom","current","project"].indexOf(K(e))-["custom","current","project"].indexOf(K(t)):"selected"===eu&&Number(t.selected)-Number(e.selected)||Date.parse(t.mtime||"")-Date.parse(e.mtime||"")),e1=e0.find(e=>e.id===eb)||e0[0]||null,e2=eS.filter(e=>e0.some(t=>t.id===e)),e4=(null==eY?void 0:eY.trim())?eH:eR,e3=(e,t,r)=>{let o=U(e,t,r);eP(o),eT(function(e){try{let t=JSON.parse(window.localStorage.getItem(e)||"[]");return Array.isArray(t)?t.filter(e=>("user"===e.role||"assistant"===e.role)&&"string"==typeof e.content).slice(-30):[]}catch(e){return[]}}(o)),eB(""),eO(!1),eM([]),e$(!1)},e8=r=>{if(null==r?void 0:r.projectRoot)return void O(r.projectRoot).then(()=>{t.success(e("common.success")),eq()}).catch(()=>t.error(e("common.error")));let o="new:".concat(Date.now());er(null),ed(!0),es(""),el(""),e3(null,"new",o),ee(!0)},e6=async()=>{if(!ea.trim())return void t.error("请输入名称");ec(!0);try{if(et)await E(et.customizePath,eo,W(et)?ea.trim():void 0),t.success(e("common.success"));else{let r=await R(ea.trim(),eo||"# ".concat(ea.trim(),"\n"));!function(e,t){if(!e||!t||e===t)return;let r=window.localStorage.getItem(e);r&&!window.localStorage.getItem(t)&&window.localStorage.setItem(t,r)}(ez,U({id:r.id,projectId:r.id,projectName:ea.trim(),customizePath:r.id,content:eo,mtime:"",hasFile:!0,isCurrent:!1,selected:!1,source:"custom"},ea.trim())),t.success(e("common.success"))}ee(!1),await eq()}catch(r){t.error(e("common.error"))}finally{ec(!1)}},e5=async e=>{let t=Array.from(new Set([...eD,...eR.filter(t=>e.includes("@".concat(t.relativePath))).map(e=>e.relativePath)])).slice(0,3),r=[];for(let e of t){let t=await D(e);t&&r.push({relativePath:e,content:t})}return r},e7=async()=>{let e=eF.trim();if(!e||eE)return;let r=[...ek,{role:"user",content:e}];eT(r),eB(""),e$(!1),eO(!0);try{let t=await e5(e),o=await J({name:ea||(null==et?void 0:et.projectName)||"未命名提示词",content:eo,message:e,history:ek,references:t});eT([...r,{role:"assistant",content:o.content||"AI 未返回内容"}])}catch(e){t.error(e instanceof Error?e.message:"AI 对话失败,请检查模型配置"),eT(r)}finally{eO(!1)}},e9=async(r,o)=>{let l=o?Array.from(new Set([...Q.filter(e=>e.selected).map(e=>e.id),r.id])):Q.filter(e=>e.selected&&e.id!==r.id).map(e=>e.id);try{await I(l),V(e=>e.map(e=>({...e,selected:l.includes(e.id)})))}catch(r){t.error(e("common.error"))}},te=async r=>{let o=Q.filter(e=>e.selected).map(e=>e.id),l=r?Array.from(new Set([...o,...e2])):o.filter(e=>!e2.includes(e));try{await I(l),V(e=>e.map(e=>({...e,selected:l.includes(e.id)}))),eA([]),t.success(e("common.success"))}catch(r){t.error(e("common.error"))}},tt=async r=>{try{if(!(await fetch("/api/prompt",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:r.projectId,filePath:r.customizePath})})).ok)throw Error("Failed");t.success(e("common.success")),eA(e=>e.filter(e=>e!==r.id)),await eq()}catch(r){t.error(e("common.error"))}},tr=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"custom",r="checked"===e?Q.filter(e=>e2.includes(e.id)):"filtered"===e?e0:eV;L("customize-prompts-".concat(new Date().toISOString().slice(0,10),".json"),X(r)),t.success("已导出 ".concat(r.length," 条提示词"))},to=async e=>{if(e){eC(!0);try{let r=await e.text(),o=JSON.parse(r),l=await H(o);t.success("已导入 ".concat(l.imported," 条提示词")),await eq()}catch(e){t.error("导入失败,请确认 JSON 文件格式正确")}finally{eC(!1),eG.current&&(eG.current.value="")}}},tl=t=>{let r=K(t);return(0,o.jsxs)(n.A,{size:4,wrap:!0,children:[(0,o.jsx)(c.A,{color:"custom"===r?"cyan":"current"===r?"green":"project"===r?"blue":"default",style:{margin:0},children:e("custom"===r?"prompt.customPrompt":"current"===r?"prompt.currentProject":"project"===r?"prompt.otherProjects":"prompt.allPrompts")}),t.selected&&(0,o.jsx)(c.A,{color:"purple",style:{margin:0},children:e("prompt.selected")}),!t.hasFile&&(0,o.jsx)(c.A,{style:{margin:0},children:e("prompt.missingFileStatus")})]})},ta=r=>(0,o.jsxs)(n.A,{size:6,children:[r.hasFile&&(0,o.jsx)(i.A,{checked:r.selected,onChange:e=>{e9(r,e.target.checked)},children:e("prompt.selected")}),!r.hasFile&&r.projectRoot&&(0,o.jsx)(d.Ay,{size:"small",icon:(0,o.jsx)(f.A,{}),onClick:()=>e8(r),children:e("common.add")}),r.hasFile&&(0,o.jsx)(d.Ay,{size:"small",icon:(0,o.jsx)(b.A,{}),onClick:()=>{er(r),ed(!1),es(r.projectName),el(r.content||""),e3(r,r.projectName),ee(!0)},children:e("common.edit")}),r.hasFile&&(0,o.jsx)(d.Ay,{size:"small",icon:(0,o.jsx)(w.A,{}),onClick:()=>{var e;return e=r,void(L("customize-prompt-".concat(e.projectName.trim().replace(/[\\/:*?"<>|]/g,"-").slice(0,80)||"untitled","-").concat(new Date().toISOString().slice(0,10),".json"),X([e])),t.success("已导出 1 条提示词"))},children:"导出"}),(0,o.jsx)(p.A,{title:W(r)?"删除自定义提示词?":"删除项目记录及文件?",onConfirm:()=>{tt(r)},children:(0,o.jsx)(d.Ay,{size:"small",danger:!0,icon:(0,o.jsx)(S.A,{})})})]});return r?(0,o.jsxs)("div",{className:"space-y-12",children:[(0,o.jsx)(m.A,{active:!0,title:!0,paragraph:{rows:1}}),(0,o.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Array.from({length:4}).map((e,t)=>(0,o.jsx)("div",{className:"p-4 border border-[var(--borderColor)]",children:(0,o.jsx)(m.A,{active:!0,paragraph:{rows:4}})},t))})]}):(0,o.jsxs)("div",{className:"space-y-8 animateFadeIn",children:[(0,o.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end justify-between gap-4 pb-6 border-b border-[var(--borderColor)]",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("h1",{className:"text-3xl font-extrabold tracking-tight text-[var(--colorText)] mb-2",children:e("nav.promptManagement")}),(0,o.jsx)("p",{className:"text-sm text-[var(--colorTextSecondary)]",children:e("prompt.description")})]}),(0,o.jsxs)(n.A,{wrap:!0,children:[eQ&&(0,o.jsxs)(c.A,{color:"green",style:{lineHeight:"22px"},bordered:!1,children:[(0,o.jsx)(N.A,{})," ",eQ.projectRoot]}),(0,o.jsx)("input",{ref:eG,type:"file",accept:"application/json,.json",style:{display:"none"},onChange:e=>{var t;to(null==(t=e.target.files)?void 0:t[0])}}),(0,o.jsx)(d.Ay,{icon:(0,o.jsx)(C.A,{}),loading:eN,onClick:()=>{var e;return null==(e=eG.current)?void 0:e.click()},children:e("prompt.import")}),(0,o.jsx)(d.Ay,{icon:(0,o.jsx)(w.A,{}),disabled:0===e0.length,onClick:()=>tr("filtered"),children:e("prompt.exportFiltered")}),(0,o.jsx)(d.Ay,{type:"primary",icon:(0,o.jsx)(f.A,{}),onClick:()=>e8(),className:"shadow-none",children:e("prompt.createPrompt")})]})]}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-3 bg-[var(--colorBgHover)] p-2 rounded-lg",children:[(0,o.jsx)(x.A,{prefix:(0,o.jsx)(k.A,{className:"text-[var(--colorTextTertiary)]"}),allowClear:!0,placeholder:e("prompt.searchPrompt"),value:ej,onChange:e=>ef(e.target.value),style:{width:280},bordered:!1,className:"bg-transparent shadow-none focus:bg-[var(--colorBgElevated)]"}),(0,o.jsx)(h.A,{value:ep,onChange:em,style:{width:150},variant:"borderless",options:[{label:"".concat(e("prompt.allPrompts")," (").concat(eZ.all,")"),value:"all"},{label:"".concat(e("prompt.customPrompt")," (").concat(eZ.custom,")"),value:"custom"},{label:"".concat(e("prompt.currentProject")," (").concat(eZ.current,")"),value:"current"},{label:"".concat(e("prompt.otherProjects")," (").concat(eZ.project,")"),value:"project"}]}),(0,o.jsx)("div",{className:"w-[1px] h-4 bg-[var(--borderColorStrong)] mx-1"}),(0,o.jsx)(h.A,{value:ex,onChange:eh,style:{width:130},variant:"borderless",options:[{label:e("prompt.promptStatus"),value:"all"},{label:"".concat(e("prompt.selected")," (").concat(eZ.selected,")"),value:"selected"},{label:"".concat(e("prompt.unselected")," (").concat(eZ.unselected,")"),value:"unselected"},{label:"".concat(e("prompt.hasFileStatus")," (").concat(eZ.hasFile,")"),value:"hasFile"},{label:"".concat(e("prompt.missingFileStatus")," (").concat(eZ.missingFile,")"),value:"missingFile"}]}),(0,o.jsx)(h.A,{value:eu,onChange:eg,style:{width:140},variant:"borderless",options:[{label:e("prompt.sortByMtime"),value:"mtime"},{label:e("prompt.sortByName"),value:"name"},{label:e("prompt.sortBySource"),value:"source"},{label:e("prompt.sortBySelected"),value:"selected"}]}),(0,o.jsx)("div",{className:"flex-1"}),(0,o.jsx)(u.A,{value:ev,onChange:e=>ey(e),options:[{label:(0,o.jsx)(T.A,{}),value:"list"},{label:(0,o.jsx)(z.A,{}),value:"card"}],className:"bg-transparent"})]}),(0,o.jsxs)("div",{className:"grid grid-cols-1 xl:grid-cols-[280px_1fr] gap-8 items-start",children:[(0,o.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("div",{className:"text-[10px] font-semibold text-[var(--colorTextTertiary)] uppercase tracking-widest mb-3 px-2",children:e("prompt.groupNav")}),(0,o.jsx)("div",{className:"space-y-0.5",children:[["all",e("prompt.allPrompts"),eZ.all],["custom",e("prompt.customPrompt"),eZ.custom],["current",e("prompt.currentProject"),eZ.current],["project",e("prompt.otherProjects"),eZ.project]].map(e=>{let[t,r,l]=e;return(0,o.jsxs)("button",{onClick:()=>em(t),className:"w-full text-left px-3 py-2 rounded-lg flex justify-between items-center transition-all ".concat(ep===t?"bg-[var(--colorBgSelected)] text-[var(--colorAccent)] font-medium shadow-sm":"text-[var(--colorTextSecondary)] hover:bg-[var(--colorBgHover)] hover:text-[var(--colorText)]"),children:[(0,o.jsx)("span",{className:"text-sm",children:r}),(0,o.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded-full ".concat(ep===t?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"bg-[var(--colorFillAlter)] text-[var(--colorTextTertiary)]"),children:l})]},t)})}),(0,o.jsx)("div",{className:"my-4 border-t border-[var(--borderColor)] mx-2"}),(0,o.jsx)("div",{className:"space-y-0.5",children:[["selected",e("prompt.selected"),eZ.selected],["unselected",e("prompt.unselected"),eZ.unselected]].map(e=>{let[t,r,l]=e;return(0,o.jsxs)("button",{onClick:()=>eh(ex===t?"all":t),className:"w-full text-left px-3 py-2 rounded-lg flex justify-between items-center transition-all ".concat(ex===t?"bg-[var(--colorBgSelected)] text-[var(--colorAccent)] font-medium shadow-sm":"text-[var(--colorTextSecondary)] hover:bg-[var(--colorBgHover)] hover:text-[var(--colorText)]"),children:[(0,o.jsx)("span",{className:"text-sm",children:r}),(0,o.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded-full ".concat(ex===t?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"bg-[var(--colorFillAlter)] text-[var(--colorTextTertiary)]"),children:l})]},t)})})]}),(0,o.jsxs)("div",{children:[(0,o.jsx)("div",{className:"text-xs font-semibold text-[var(--colorTextSecondary)] uppercase tracking-wider mb-4",children:e("prompt.detailPreview")}),e1?(0,o.jsxs)("div",{className:"space-y-4",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,o.jsx)(A.A,{className:"text-[var(--colorTextSecondary)] shrink-0"}),(0,o.jsx)("strong",{className:"min-w-0 truncate text-base",children:e1.projectName})]}),(0,o.jsx)("div",{className:"min-w-0 overflow-hidden",children:tl(e1)}),(0,o.jsxs)("div",{className:"text-xs text-[var(--colorTextSecondary)] space-y-2 break-all",children:[(0,o.jsxs)("div",{children:["更新时间:",G(e1.mtime)]}),(0,o.jsxs)("div",{children:["文件路径:",e1.customizePath||"-"]}),(0,o.jsxs)("div",{children:["项目路径:",e1.projectRoot||"-"]})]}),(0,o.jsx)("div",{className:"p-3 bg-[var(--colorBgHover)] rounded-md text-xs text-[var(--colorTextSecondary)] max-h-[300px] overflow-auto whitespace-pre-wrap",children:$(e1,800)||"暂无内容预览"}),(0,o.jsx)("div",{children:ta(e1)})]}):(0,o.jsx)(g.A,{image:g.A.PRESENTED_IMAGE_SIMPLE,description:"请选择一个提示词",className:"my-8"})]})]}),(0,o.jsxs)("div",{className:"min-w-0",children:[e2.length>0&&(0,o.jsxs)("div",{className:"flex items-center gap-3 flex-wrap p-3 mb-6 bg-[var(--colorBgHover)] rounded-md border border-[var(--borderColor)]",children:[(0,o.jsxs)("span",{className:"font-semibold text-sm",children:["已选择 ",e2.length," 项"]}),(0,o.jsx)(d.Ay,{size:"small",onClick:()=>{te(!0)},children:e("prompt.batchSelect")}),(0,o.jsx)(d.Ay,{size:"small",onClick:()=>{te(!1)},children:e("prompt.cancelSelect")}),(0,o.jsx)(d.Ay,{size:"small",icon:(0,o.jsx)(w.A,{}),onClick:()=>tr("checked"),children:e("prompt.exportSelected")}),(0,o.jsx)(d.Ay,{size:"small",onClick:()=>eA([]),children:e("prompt.clearSelect")})]}),0===e0.length?(0,o.jsx)("div",{className:"py-20 text-center border border-[var(--borderColor)] rounded-lg",children:(0,o.jsx)(g.A,{description:ej||"all"!==ex?e("prompt.noMatchDesc"):e("prompt.noPromptInGroup")})}):"list"===ev?(0,o.jsx)("div",{className:"flex flex-col gap-3",children:e0.map(e=>{let t=$(e,180),r=(null==e1?void 0:e1.id)===e.id;return(0,o.jsxs)("div",{onClick:()=>ew(e.id),className:"group grid grid-cols-[28px_1fr_auto] gap-4 items-center p-4 rounded-xl border border-transparent transition-all cursor-pointer ".concat(r?"bg-[var(--colorBgSelected)] shadow-none":"bg-transparent hover:bg-[var(--colorBgHover)]"),style:r?{boxShadow:"0 0 0 1px var(--borderColorSelected) inset"}:{},children:[(0,o.jsx)(i.A,{checked:eS.includes(e.id),onClick:e=>e.stopPropagation(),onChange:t=>eA(r=>t.target.checked?Array.from(new Set([...r,e.id])):r.filter(t=>t!==e.id))}),(0,o.jsxs)("div",{className:"min-w-0",children:[(0,o.jsxs)("div",{className:"flex items-center gap-3 mb-1",children:[(0,o.jsx)(A.A,{className:e.isCurrent?"text-[var(--colorOk)]":"text-[var(--colorTextSecondary)]"}),(0,o.jsx)("span",{className:"font-semibold truncate text-[var(--colorText)] text-base",children:e.projectName}),tl(e)]}),(0,o.jsxs)("div",{className:"text-xs text-[var(--colorTextTertiary)] truncate flex items-center gap-1",children:[(0,o.jsx)(N.A,{})," ",e.projectRoot||e.customizePath||"本地提示词"," \xb7 ",G(e.mtime)]}),t&&(0,o.jsx)("div",{className:"text-sm text-[var(--colorTextSecondary)] mt-2 line-clamp-2 leading-relaxed",children:t})]}),(0,o.jsx)("div",{onClick:e=>e.stopPropagation(),className:"opacity-0 group-hover:opacity-100 transition-opacity",children:ta(e)})]},e.id)})}):(0,o.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:e0.map(e=>{let t=$(e,180),r=(null==e1?void 0:e1.id)===e.id;return(0,o.jsxs)("div",{onClick:()=>ew(e.id),className:"group flex flex-col p-5 rounded-2xl transition-all cursor-pointer ".concat(r?"bg-[var(--colorBgSelected)] shadow-none":"bg-[var(--colorBgContainer)] hover:bg-[var(--colorBgHover)] shadow-sm"," border border-transparent"),style:r?{boxShadow:"0 0 0 1px var(--borderColorSelected) inset"}:{},children:[(0,o.jsx)("div",{className:"flex items-start justify-between gap-3 mb-4 min-w-0",children:(0,o.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[(0,o.jsx)(i.A,{checked:eS.includes(e.id),onClick:e=>e.stopPropagation(),onChange:t=>eA(r=>t.target.checked?Array.from(new Set([...r,e.id])):r.filter(t=>t!==e.id))}),(0,o.jsx)("span",{className:"font-bold text-base text-[var(--colorText)] truncate mb-1",children:e.projectName})]})}),(0,o.jsx)("div",{className:"mb-3",children:tl(e)}),(0,o.jsxs)("div",{className:"text-xs text-[var(--colorTextTertiary)] truncate flex items-center gap-1 mb-4",children:[(0,o.jsx)(N.A,{}),e.projectRoot||e.customizePath||"本地提示词"]}),t?(0,o.jsx)("div",{className:"text-sm text-[var(--colorTextSecondary)] line-clamp-3 leading-relaxed mb-4",children:t}):(0,o.jsx)("div",{className:"text-sm text-[var(--colorTextQuaternary)] italic mb-4",children:"暂无内容预览"}),(0,o.jsxs)("div",{className:"mt-auto pt-4 border-t border-[var(--borderColor)] flex justify-between items-center",onClick:e=>e.stopPropagation(),children:[(0,o.jsx)("span",{className:"text-xs font-medium text-[var(--colorTextTertiary)]",children:G(e.mtime)}),(0,o.jsx)("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:ta(e)})]})]},e.id)})})]})]}),(0,o.jsxs)(v.A,{title:ei?e("prompt.createPrompt"):et&&W(et)?"".concat(e("prompt.customPrompt")," — ").concat(ea||et.projectName):"".concat(e("prompt.currentProject")," — ").concat((null==et?void 0:et.projectName)||""),open:Z,onClose:()=>ee(!1),width:1080,maskClosable:!1,styles:{body:{padding:"24px 32px",display:"grid",gridTemplateRows:"minmax(320px, 1fr) 420px",gap:24,height:"100%"},header:{borderBottom:"1px solid var(--colorBorderSecondary)",padding:"16px 32px"}},extra:(0,o.jsxs)(n.A,{children:[(0,o.jsx)(d.Ay,{onClick:()=>ee(!1),children:e("common.cancel")}),(0,o.jsx)(d.Ay,{type:"primary",loading:en,onClick:()=>{e6()},children:e("common.save")})]}),children:[(0,o.jsxs)("div",{style:{minHeight:0,display:"flex",flexDirection:"column"},children:[(0,o.jsx)("div",{style:{marginBottom:12},children:ei||et&&W(et)?(0,o.jsxs)(n.A,{direction:"vertical",size:6,style:{width:"100%"},children:[(0,o.jsx)(x.A,{placeholder:e("prompt.promptName"),value:ea,onChange:e=>es(e.target.value),style:{maxWidth:520}}),!ei&&(0,o.jsx)("div",{style:{fontSize:12,color:"var(--colorTextSecondary)"},children:null==et?void 0:et.customizePath})]}):(0,o.jsx)("div",{style:{fontSize:12,color:"var(--colorTextSecondary)"},children:null==et?void 0:et.customizePath})}),(0,o.jsx)(x.A.TextArea,{value:eo,onChange:e=>el(e.target.value),style:{flex:1,minHeight:280,fontFamily:"SF Mono, Monaco, Consolas, monospace",fontSize:13,resize:"none"}})]}),(0,o.jsxs)("div",{style:{minHeight:0,border:"1px solid var(--colorBorderSecondary)",borderRadius:10,background:"var(--colorBgContainer)",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 8px 24px rgba(15, 23, 42, 0.06)"},children:[(0,o.jsxs)("div",{style:{padding:"10px 12px",borderBottom:"1px solid var(--colorBorderSecondary)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,o.jsxs)(n.A,{size:6,children:[(0,o.jsx)(P.A,{style:{color:"var(--colorAccent)"}}),(0,o.jsx)("span",{style:{fontWeight:600},children:e("prompt.aiPromptAssistant")})]}),(0,o.jsxs)(n.A,{size:6,children:[ek.length>0&&(0,o.jsx)(d.Ay,{size:"small",onClick:()=>eT([]),children:e("prompt.clearHistory")}),eE?(0,o.jsx)(c.A,{color:"processing",style:{margin:0},children:e("prompt.generating")}):(0,o.jsx)(c.A,{color:"blue",style:{margin:0},children:e("prompt.canConverse")})]})]}),(0,o.jsx)("div",{ref:eX,style:{flex:1,minHeight:0,overflowY:"auto",padding:14,background:"var(--colorFillAlter)"},children:0!==ek.length||eE?(0,o.jsxs)(n.A,{direction:"vertical",size:12,style:{width:"100%"},children:[ek.map((r,l)=>{let a="user"===r.role;return(0,o.jsx)("div",{style:{display:"flex",justifyContent:a?"flex-end":"flex-start"},children:(0,o.jsxs)("div",{style:{maxWidth:"78%",padding:"10px 12px",borderRadius:12,background:a?"var(--colorFillSecondary)":"var(--colorBgContainer)",color:"var(--colorText)",border:"1px solid var(--colorBorderSecondary)",whiteSpace:"pre-wrap",lineHeight:1.7,fontSize:13,transition:"all .2s ease"},children:[r.content,!a&&(0,o.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:8},children:(0,o.jsx)(d.Ay,{size:"small",type:"primary",onClick:()=>{el(r.content),t.success("已应用到编辑内容,请确认后保存")},children:e("prompt.apply")})})]})},"".concat(r.role,"-").concat(l))}),eE&&(0,o.jsx)("div",{style:{display:"flex",justifyContent:"flex-start"},children:(0,o.jsxs)("div",{style:{padding:"10px 12px",borderRadius:12,background:"var(--colorBgContainer)",border:"1px solid var(--colorBorderSecondary)",color:"var(--colorTextSecondary)",fontSize:13},children:[(0,o.jsx)(y.A,{size:"small",style:{marginRight:8}}),e("prompt.aiAnalyzing")]})})]}):(0,o.jsx)(g.A,{image:g.A.PRESENTED_IMAGE_SIMPLE,description:e("prompt.mentionRecallHint")})}),(0,o.jsx)(j.A,{style:{margin:0}}),(0,o.jsxs)("div",{style:{padding:12},children:[eD.length>0&&(0,o.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginBottom:8},children:eD.map(e=>(0,o.jsxs)(c.A,{closable:!0,onClose:()=>eM(t=>t.filter(t=>t!==e)),style:{margin:0,maxWidth:360,overflow:"hidden",textOverflow:"ellipsis"},children:["@",e]},e))}),eU&&(0,o.jsxs)("div",{style:{maxHeight:260,overflowY:"auto",marginBottom:8,border:"1px solid var(--colorBorderSecondary)",borderRadius:12,background:"var(--colorBgElevated, var(--colorBgContainer))",boxShadow:"0 16px 40px rgba(15, 23, 42, 0.14)"},children:[(0,o.jsxs)("div",{style:{position:"sticky",top:0,zIndex:1,padding:"10px 12px",borderBottom:"1px solid var(--colorBorderSecondary)",background:"var(--colorBgElevated, var(--colorBgContainer))",display:"flex",justifyContent:"space-between",gap:12,alignItems:"center"},children:[(0,o.jsxs)("div",{children:[(0,o.jsx)("div",{style:{color:"var(--colorText)",fontSize:13,fontWeight:700},children:e("prompt.recallKbFiles")}),(0,o.jsx)("div",{style:{color:"var(--colorTextSecondary)",fontSize:11},children:e("prompt.recallLimitHint")})]}),(0,o.jsx)(c.A,{color:eY?"blue":"default",style:{margin:0,maxWidth:240,overflow:"hidden",textOverflow:"ellipsis"},children:eY?"@".concat(eY):e("prompt.inputAtKeyword")})]}),eJ?(0,o.jsxs)("div",{style:{padding:14,color:"var(--colorTextSecondary)",fontSize:12},children:[(0,o.jsx)(y.A,{size:"small",style:{marginRight:8}}),e("prompt.loadingKbFiles")]}):0===eR.length?(0,o.jsx)("div",{style:{padding:14,color:"var(--colorTextSecondary)",fontSize:12},children:e("prompt.noRecallableKbFiles")}):0===e4.length?(0,o.jsx)("div",{style:{padding:14,color:"var(--colorTextSecondary)",fontSize:12},children:eW?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(y.A,{size:"small",style:{marginRight:8}}),e("prompt.searchingKbContent")]}):e("prompt.noMatchingKbFiles")}):(0,o.jsxs)(o.Fragment,{children:[eW&&(0,o.jsxs)("div",{style:{padding:"8px 12px",color:"var(--colorTextSecondary)",fontSize:12,borderBottom:"1px solid var(--colorBorderSecondary)"},children:[(0,o.jsx)(y.A,{size:"small",style:{marginRight:8}}),e("prompt.continueSearchingKb")]}),e4.slice(0,30).map(t=>(0,o.jsxs)("div",{onMouseDown:e=>{var r;e.preventDefault(),r=t.relativePath,eM(e=>e.includes(r)?e:[...e,r]),eB(e=>e.replace(/(^|\s)@([^\s@]*)$/,"$1@".concat(r," "))),e$(!1)},style:{padding:"10px 12px",cursor:"pointer",borderBottom:"1px solid var(--colorBorderSecondary)",fontSize:12,display:"grid",gridTemplateColumns:"22px minmax(0, 1fr) auto",gap:10,alignItems:"center"},children:[(0,o.jsx)("div",{style:{width:22,height:22,borderRadius:7,background:"var(--colorFillSecondary)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,o.jsx)(A.A,{style:{color:"var(--colorAccent)"}})}),(0,o.jsxs)("div",{style:{minWidth:0},children:[(0,o.jsx)("div",{style:{color:"var(--colorText)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:700},children:t.relativePath}),(0,o.jsxs)("div",{style:{color:"var(--colorTextSecondary)",fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[t.category||e("prompt.unclassified")," \xb7 ",t.format||e("prompt.unknownFormat"),"number"==typeof t.score?" \xb7 score ".concat(t.score.toFixed(2)):""]})]}),(0,o.jsxs)(n.A,{size:4,children:[(0,o.jsx)(c.A,{color:"content"===t.matchedBy?"purple":"disk"===t.matchedBy?"orange":"blue",style:{margin:0},children:"content"===t.matchedBy?e("prompt.contentMatch"):"disk"===t.matchedBy?e("prompt.diskFile"):e("prompt.fileMatch")}),(0,o.jsx)(c.A,{style:{margin:0},children:t.status})]})]},t.relativePath))]})]}),(0,o.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"flex-end"},children:[(0,o.jsx)(x.A.TextArea,{value:eF,onChange:e=>{let t=e.target.value;eB(t),e$(null!==Y(t))},onFocus:()=>e$(null!==Y(eF)),onPressEnter:e=>{e.shiftKey||(e.preventDefault(),e7())},disabled:eE,placeholder:e("prompt.mentionRecallPlaceholder"),autoSize:{minRows:2,maxRows:5},style:{fontSize:13,lineHeight:1.6}}),(0,o.jsx)(d.Ay,{type:"primary",icon:(0,o.jsx)(F.A,{}),loading:eE,disabled:!eF.trim(),onClick:()=>{e7()},children:e("prompt.send")})]})]})]})]})]})}}},e=>{e.O(0,[576,985,195,478,636,593,792],()=>e(e.s=27549)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[979],{9137:(e,r,t)=>{"use strict";t.d(r,{Ay:()=>C});var a=t(9750),s=t(97109),o=t(42644),n=t(10252),l=t(74567),c=t(48921),i=t(98379),d=t(3638),x=t(632),m=t(34475),p=t(52093),g=t(60815),u=t(5741);let f=null,h=e=>e(),v=[],b={};function y(){let{getContainer:e,duration:r,rtl:t,maxCount:a,top:s,stack:o}=b,n=e?.()||document.body;return{getContainer:()=>n,duration:r,rtl:t,maxCount:a,top:s,stack:o}}let w=s.forwardRef((e,r)=>{let{messageConfig:t,sync:a}=e,{getPrefixCls:o}=(0,s.useContext)(l.QO),c=b.prefixCls||o("message"),i=(0,s.useContext)(n.B),[d,x]=(0,g.y)({...t,prefixCls:c,...i.message});return s.useImperativeHandle(r,()=>{let e={...d};return Object.keys(e).forEach(r=>{e[r]=(...e)=>(a(),d[r].apply(d,e))}),{instance:e,sync:a}}),x}),j=s.forwardRef((e,r)=>{let[t,a]=s.useState(y),o=()=>{a(y)};s.useEffect(o,[]);let n=(0,c.cr)(),l=n.getRootPrefixCls(),i=n.getIconPrefixCls(),d=n.getTheme(),x=s.createElement(w,{ref:r,sync:o,messageConfig:t});return s.createElement(c.Ay,{prefixCls:l,iconPrefixCls:i,theme:d},n.holderRender?n.holderRender(x):x)}),N=()=>{if(!f){let e=document.createDocumentFragment(),r={fragment:e};f=r,h(()=>{(0,o.XX)(s.createElement(j,{ref:e=>{let{instance:t,sync:a}=e||{};Promise.resolve().then(()=>{!r.instance&&t&&(r.instance=t,r.sync=a,N())})}}),e)});return}f.instance&&(v.forEach(e=>{let{type:r,skipped:t}=e;if(!t)switch(r){case"open":h(()=>{let r=f.instance.open({...b,...e.config});r?.then(e.resolve),e.setCloseFn(r)});break;case"destroy":h(()=>{f?.instance.destroy(e.key)});break;default:h(()=>{var t;let s=(t=f.instance)[r].apply(t,(0,a.A)(e.args));s?.then(e.resolve),e.setCloseFn(s)})}}),v=[])},A={open:function(e){let r=(0,u.E)(r=>{let t,a={type:"open",config:e,resolve:r,setCloseFn:e=>{t=e}};return v.push(a),()=>{t?h(()=>{t()}):a.skipped=!0}});return N(),r},destroy:e=>{v.push({type:"destroy",key:e}),N()},config:function(e){b={...b,...e},h(()=>{f?.sync?.()})},useMessage:g.A,_InternalPanelDoNotUseOrYouWillBeFired:m.Ay,_InternalListDoNotUseOrYouWillBeFired:e=>{let{items:r,classNames:t,style:a}=e,{getPrefixCls:o}=(0,l.TP)("message"),n=o("message"),c=(0,x.A)(n),[g,u]=(0,p.A)(n,c),f=`${n}-notice`,h=r.map(e=>{let{content:r,duration:t,key:a,type:s}=e,o=s?`${f}-icon-${s}`:void 0;return{key:a,duration:t,icon:(0,m.HC)(s),title:r,className:`${f}-${s}`,classNames:{wrapper:`${n}-${s}`,icon:o}}});return s.createElement(i.qb,{prefixCls:n,placement:"top",configList:h,className:(0,d.$)(g,u,c),classNames:{...t,wrapper:t?.wrapper,title:t?.title},style:a,stack:!1})}};["success","info","warning","error","loading"].forEach(e=>{A[e]=(...r)=>(function(e,r){(0,c.cr)();let t=(0,u.E)(t=>{let a,s={type:e,args:r,resolve:t,setCloseFn:e=>{a=e}};return v.push(s),()=>{a?h(()=>{a()}):s.skipped=!0}});return N(),t})(e,r)});let C=A},12446:(e,r)=>{"use strict";r.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"}},{tag:"path",attrs:{d:"M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"}}]},name:"info-circle",theme:"outlined"}},14995:(e,r)=>{"use strict";r.A={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"}}]},name:"reload",theme:"outlined"}},29606:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>C});var a=t(65321),s=t(97109),o=t(35292),n=t(9137),l=t(11702),c=t(88762),i=t(7576),d=t(85114),x=t(26171),m=t(21289),p=t(84253),g=t(30486),u=t(99811),f=t(58209),h=t(12446),v=t(88483);function b(){return(b=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}let y=s.forwardRef((e,r)=>s.createElement(v.A,b({},e,{ref:r,icon:h.A})));var w=t(48321),j=t(6578);let{Text:N,Paragraph:A}=o.A;function C(){let e=(0,w.Vr)(),[r,t]=(0,s.useState)([]),[o,h]=(0,s.useState)(!0),[v,b]=(0,s.useState)(""),A=async()=>{h(!0);try{t((await (0,j.oH)(500)).logs)}catch(e){n.Ay.error(e instanceof Error?e.message:"加载日志失败")}finally{h(!1)}};(0,s.useEffect)(()=>{A()},[]);let C=(0,s.useMemo)(()=>{let e=v.trim().toLowerCase();return e?r.filter(r=>[r.id,r.level,r.source,r.functionName,r.message,r.stack].filter(Boolean).some(r=>String(r).toLowerCase().includes(e))):r},[v,r]),T=[{title:"Time",dataIndex:"createdAt",width:160,render:e=>(0,a.jsx)("span",{className:"text-xs text-[var(--colorTextSecondary)] font-mono",children:new Date(e).toLocaleString()})},{title:"Level",dataIndex:"level",width:80,render:e=>(0,a.jsx)(l.A,{color:"error"===e?"error":"warn"===e?"warning":"blue",bordered:!1,className:"m-0 text-[10px] uppercase tracking-wider",children:e})},{title:"Source",dataIndex:"source",width:220,render:e=>(0,a.jsx)("span",{className:"text-xs font-mono text-[var(--colorTextSecondary)] break-all",children:e})},{title:"Message",dataIndex:"message",render:e=>(0,a.jsx)("div",{className:"text-sm text-[var(--colorText)] max-w-3xl whitespace-normal break-words leading-relaxed",title:e,children:e})},{title:"Req ID",dataIndex:"id",width:120,render:e=>(0,a.jsx)(N,{copyable:!0,className:"text-[10px] font-mono text-[var(--colorTextTertiary)]",children:e.slice(0,8)})}];return o&&0===r.length?(0,a.jsxs)("div",{className:"space-y-8 animateFadeIn",children:[(0,a.jsx)(c.A,{active:!0,title:!0,paragraph:{rows:1}}),(0,a.jsx)(c.A,{active:!0,paragraph:{rows:12}})]}):(0,a.jsxs)("div",{className:"h-[calc(100vh-140px)] flex flex-col",children:[(0,a.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 pb-4 border-b border-[var(--borderColor)] shrink-0 animateFadeIn",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-2xl font-bold tracking-tight text-[var(--colorText)] mb-1",children:e("nav.systemLogs")}),(0,a.jsx)("p",{className:"text-xs text-[var(--colorTextSecondary)]",children:e("logs.monitorSystem")})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(i.A,{placeholder:e("logs.searchLogs"),prefix:(0,a.jsx)(g.A,{className:"text-[var(--colorTextTertiary)]"}),value:v,onChange:e=>b(e.target.value),allowClear:!0,className:"w-[260px] bg-[var(--colorBgHover)] border-transparent"}),(0,a.jsx)(d.Ay,{icon:(0,a.jsx)(u.A,{}),loading:o,onClick:()=>void A(),className:"shadow-none",children:e("logs.refresh")}),(0,a.jsx)(x.A,{title:e("logs.clearConfirm"),onConfirm:()=>{(async()=>{await (0,j.hH)(),n.Ay.success(e("common.success")),await A()})()},children:(0,a.jsx)(d.Ay,{danger:!0,icon:(0,a.jsx)(f.A,{}),className:"shadow-none border-transparent",children:e("logs.clear")})})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 py-3 px-1 text-xs text-[var(--colorTextTertiary)] shrink-0 animateFadeIn stagger-1",children:[(0,a.jsx)(y,{})," ",e("logs.logStorageInfo")," ",(0,a.jsx)("code",{className:"bg-[var(--colorBgHover)] px-1 rounded",children:"~/.customize-agent/logs/errors.jsonl"}),". ",e("logs.maxLoaded")]}),(0,a.jsx)("div",{className:"flex-1 overflow-hidden bg-[var(--colorBg)] rounded-lg animateFadeIn stagger-2",children:(0,a.jsx)(m.A,{rowKey:"id",loading:o,dataSource:C,columns:T,size:"middle",className:"h-full modern-table",scroll:{y:"calc(100vh - 280px)"},locale:{emptyText:(0,a.jsx)(p.A,{description:e("logs.noLogsFound"),className:"py-20"})},pagination:!1,rowClassName:"hover:bg-[var(--colorBgHover)] transition-colors cursor-pointer",expandable:{expandedRowRender:e=>(0,a.jsxs)("div",{className:"flex flex-col gap-4 p-4 bg-[var(--colorBgHover)]/50 border-t border-[var(--borderColor)]",children:[e.functionName&&(0,a.jsxs)("div",{className:"text-xs text-[var(--colorTextSecondary)]",children:[(0,a.jsx)("span",{className:"font-semibold uppercase tracking-wider text-[var(--colorTextTertiary)] mr-2",children:"Function"}),(0,a.jsx)("code",{className:"font-mono bg-[var(--colorBgElevated)] px-2 py-1 rounded",children:e.functionName})]}),e.request&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-[var(--colorTextTertiary)] mb-2",children:"Request Context"}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-[var(--colorBgElevated)] p-3 rounded-md border border-[var(--borderColor)] whitespace-pre-wrap break-all m-0 text-[var(--colorTextSecondary)]",children:JSON.stringify(e.request,null,2)})]}),void 0!==e.meta&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-[var(--colorTextTertiary)] mb-2",children:"Metadata"}),(0,a.jsx)("pre",{className:"text-xs font-mono bg-[var(--colorBgElevated)] p-3 rounded-md border border-[var(--borderColor)] whitespace-pre-wrap break-all m-0 text-[var(--colorTextSecondary)]",children:JSON.stringify(e.meta,null,2)})]}),e.stack&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-[var(--colorTextTertiary)] mb-2",children:"Stack Trace"}),(0,a.jsx)("pre",{className:"text-[11px] font-mono bg-[#1e1e1e] text-[#d4d4d4] p-3 rounded-md overflow-x-auto m-0 leading-relaxed",children:e.stack})]})]})}})})]})}},39214:(e,r,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/system/logs",function(){return t(29606)}])},99811:(e,r,t)=>{"use strict";t.d(r,{A:()=>l});var a=t(97109),s=t(14995),o=t(88483);function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}let l=a.forwardRef((e,r)=>a.createElement(o.A,n({},e,{ref:r,icon:s.A})))}},e=>{e.O(0,[433,576,985,375,195,289,636,593,792],()=>e(e.s=39214)),_N_E=e.O()}]);