nx-kv 0.42.2 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +1 -1
  3. package/assets/kv-get/SKILL.md +4 -4
  4. package/assets/kv-get/references/localget.md +2 -2
  5. package/package.json +1 -1
  6. package/src/core/attachmentdb/docs.js +12 -0
  7. package/src/core/attachmentdb/relations.js +17 -0
  8. package/src/core/attachmentdb.js +1 -0
  9. package/src/modules/docs/attach.js +46 -1
  10. package/src/modules/docs/brief.js +35 -4
  11. package/src/modules/docs/index.js +15 -1
  12. package/src/modules/docs/service.js +10 -6
  13. package/src/modules/localtask/action-attach.js +25 -0
  14. package/src/modules/localtask/action-flags.js +0 -1
  15. package/src/modules/localtask/action-lifecycle.js +6 -4
  16. package/src/modules/localtask/action-waiting.js +3 -3
  17. package/src/modules/localtask/repo/rows.js +3 -0
  18. package/src/modules/localtask/repo/tasks.js +18 -2
  19. package/src/modules/localtask/task-lifecycle.js +3 -3
  20. package/src/modules/localtask/task-view.js +14 -6
  21. package/src/modules/tasktool/attach-resource.js +3 -0
  22. package/src/modules/tasktool/attach.js +62 -0
  23. package/src/modules/tasktool/get.js +1 -2
  24. package/src/modules/tasktool/plugins/waitgoal-config.js +1 -1
  25. package/src/modules/tasktool/wait.js +2 -2
  26. package/src/shared/doc-title.js +71 -0
  27. package/src/web/frontend/components/md/attach-area.jsx +56 -6
  28. package/src/web/frontend/components/md/attach-common.js +16 -3
  29. package/src/web/frontend/components/md/attach-modal.jsx +42 -2
  30. package/src/web/frontend/components/md/md-panes-helpers.js +4 -1
  31. package/src/web/frontend/components/repos/get-loop-modal.jsx +1 -1
  32. package/src/web/frontend/components/task-panel/index.jsx +7 -25
  33. package/src/web/frontend/components/task-panel/layout.jsx +64 -0
  34. package/src/web/frontend/components/task-panel/page-shell.jsx +38 -0
  35. package/src/web/frontend/components/tool-acts/modules.js +2 -0
  36. package/src/web/frontend/modules/md/md-render.js +34 -11
  37. package/src/web/frontend/modules/md/progress-chain.js +29 -0
  38. package/src/web/frontend/modules/md/progress-search.js +14 -0
  39. package/src/web/frontend/modules/md/styles/chrome.css +9 -0
  40. package/src/web/frontend/modules/md/styles/panels.css +2 -0
  41. package/src/web/frontend/modules/md/styles/shell.css +2 -10
  42. package/src/web/frontend/page/dir/index.jsx +8 -5
  43. package/src/web/frontend/page/dir/landing.jsx +93 -100
  44. package/src/web/frontend/page/dir/task.jsx +19 -3
  45. package/src/web/frontend/page/doc/index.jsx +24 -12
  46. package/src/web/frontend/page/group/index.jsx +163 -80
  47. package/src/web/frontend/page/progress/index.jsx +67 -19
  48. package/src/web/frontend/styles-v2/views.css +5 -1
  49. package/src/web/public/assets/Introduction-DAXj7E6q.js +6 -0
  50. package/src/web/public/assets/{bar-yESbzCxC.js → bar-KTPTE33i.js} +1 -1
  51. package/src/web/public/assets/{cloud-BotRQcvf.js → cloud-CLco1knr.js} +1 -1
  52. package/src/web/public/assets/{composer-panel-Xru2qIma.js → composer-panel-D3N_wO9r.js} +1 -1
  53. package/src/web/public/assets/deleted-panel-B6sZddUs.js +1 -0
  54. package/src/web/public/assets/dir-DEbQhSfL.js +5 -0
  55. package/src/web/public/assets/group-CxqVtyyh.js +2 -0
  56. package/src/web/public/assets/index-DGvBoOdp.css +1 -0
  57. package/src/web/public/assets/{index-BrAIkzFc.js → index-DNB8tgNi.js} +2 -2
  58. package/src/web/public/assets/md-history-C9vOgGLz.js +39 -0
  59. package/src/web/public/assets/{overview-J1mQpmJt.js → overview-9nXafXeK.js} +1 -1
  60. package/src/web/public/assets/progress-Bx0reVYl.js +3 -0
  61. package/src/web/public/assets/{refs-FI1FMoGi.js → refs-B5YIZ9SG.js} +1 -1
  62. package/src/web/public/assets/{repos-Oaycnb4I.js → repos-Dbr-i-gg.js} +2 -2
  63. package/src/web/public/assets/{route-crumb-C8JzPIax.js → route-crumb-BfRi1GKw.js} +1 -1
  64. package/src/web/public/assets/{settings-D5wTGhPD.js → settings-B4FvZtu0.js} +1 -1
  65. package/src/web/public/assets/{status-tag-BoUoKYZK.js → status-tag-p3fo3Hbr.js} +1 -1
  66. package/src/web/public/assets/{task-BgubFzHT.js → task-CUb7dohw.js} +3 -3
  67. package/src/web/public/assets/{templates-6DQdUpiB.js → templates-BGhPIp0x.js} +1 -1
  68. package/src/web/public/assets/tool-bar-DpwpQ47h.js +1 -0
  69. package/src/web/public/index.html +2 -2
  70. package/src/web/public/assets/Introduction-CdC8MBfL.js +0 -1
  71. package/src/web/public/assets/dir-D4Q3L20K.js +0 -5
  72. package/src/web/public/assets/group-Csco0TYH.js +0 -1
  73. package/src/web/public/assets/index-CZzMw1zg.css +0 -1
  74. package/src/web/public/assets/md-history-DB5forf2.js +0 -39
  75. package/src/web/public/assets/progress-DHDlz9O9.js +0 -3
  76. package/src/web/public/assets/task-row-Bc6JBfrE.js +0 -1
  77. package/src/web/public/assets/tool-bar-DGCwnUcn.js +0 -1
@@ -1,5 +1,5 @@
1
- import{f as e,g as t,h as n,l as r,m as i,o as a,p as o,y as s}from"./task-status-BnymQMTw.js";import{n as c}from"./app-context-D7HAx67n.js";import{x as l}from"./index-BrAIkzFc.js";import{t as u}from"./route-crumb-C8JzPIax.js";import{i as d,n as f}from"./Introduction-CdC8MBfL.js";import{t as p}from"./bar-yESbzCxC.js";import{t as m}from"./member-picker-BAgkj36N.js";import{t as h}from"./button-Cmo-6aoW.js";var g=s(t(),1),_=n(),v={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function y({onClose:t,onChanged:n,repos:r,boards:a}){let s=e(),c=o(),[l,u]=(0,g.useState)(`import`),[d,f]=(0,g.useState)({}),[p,m]=(0,g.useState)({}),[h,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(``),[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(null),[E,D]=(0,g.useState)({}),[O,k]=(0,g.useState)({}),[A,j]=(0,g.useState)(`ours`),[M,ee]=(0,g.useState)(`none`),[N,P]=(0,g.useState)(``),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(!1),z=(0,g.useMemo)(()=>r||[],[r]),B=(0,g.useMemo)(()=>z.map(e=>e.key),[z]),V=(0,g.useMemo)(()=>(a||[]).map(e=>e.name),[a]),H=e=>{let t={};for(let n of B)t[n]=e;f(t)},te=e=>{let t={};for(let n of V)t[n]=e;m(t)},U=()=>{let e={};for(let t of B)e[t]=!d[t];f(e)},W=()=>s(async()=>{let e=Object.keys(d).filter(e=>d[e]),t=Object.keys(p).filter(e=>p[e]),n={repos:e.length&&e.length!==B.length?e:void 0,boards:t.length&&t.length!==V.length?t.map(e=>`board/${e}`):void 0,noUnassigned:h},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),h&&r.set(`no-unassigned`,`1`);let a=await i(`/api/repos/export`+(r.toString()?`?`+r:``));x(JSON.stringify(a,null,2)),c(`已生成布局:${a.repos.length} 个仓库 / ${a.boards.length} 个看板`)}),G=()=>{if(!b)return;let e=new Blob([b],{type:`application/json`}),t=document.createElement(`a`);t.href=URL.createObjectURL(e),t.download=`nx-kv-layout-${new Date().toISOString().slice(0,10)}.json`,t.click(),URL.revokeObjectURL(t.href)},K=async e=>{let t=e.target.files?.[0];t&&(C(await t.text()),T(null),I(null))},ne=()=>s(async()=>{if(S.trim()){R(!0);try{let e=await i(`/api/repos/import/diff`,{method:`POST`,body:{json:S}});T(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;D(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;k(n),I(null),c(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{R(!1)}}}),q=()=>s(async()=>{let e=Object.keys(E).filter(e=>E[e]),t=Object.keys(O).filter(e=>O[e]);R(!0);try{let r=await i(`/api/repos/import`,{method:`POST`,body:{json:S,strategy:A,clone:M,selection:e.length?e:void 0,boards:t.length?t:void 0}});I(r),c(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await J(),n&&await n()}finally{R(!1)}}),J=(0,g.useCallback)(async()=>{try{let e=await i(`/api/repos/import/diff`,{method:`POST`,body:{json:S}});T(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;D(t)}catch{}},[S]),re=(0,g.useMemo)(()=>w?N?w.repos.filter(e=>e.status===N):w.repos:[],[w,N]),ie=(e,t)=>s(async()=>{if(t){R(!0);try{await i(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),c(`已克隆: ${e}`),await J(),n&&await n()}finally{R(!1)}}}),ae=e=>{let t={...E};for(let n of re)t[n.key]=e;D(t)};(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopImmediatePropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let oe=(0,g.useMemo)(()=>{if(!w)return null;let e={new:0,changed:0,same:0};for(let t of w.repos)e[t.status]=(e[t.status]||0)+1;return e},[w]);return(0,_.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,_.jsxs)(`div`,{className:`rp-full-box`,children:[(0,_.jsxs)(`div`,{className:`rp-full-head`,children:[(0,_.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,_.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,_.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,_.jsx)(`button`,{className:`rp-tab`+(l===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,_.jsx)(`button`,{className:`rp-tab`+(l===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),l===`export`?(0,_.jsxs)(`div`,{className:`rp-full-body`,children:[(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,_.jsx)(`span`,{children:`导出范围`}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>H(!0),children:`全选仓库`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>H(!1),children:`全不选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:U,children:`反选`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-sel`,children:[z.map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,_.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,_.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),z.length?null:(0,_.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,_.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,_.jsx)(`span`,{children:`看板`}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>te(!0),children:`全选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>te(!1),children:`全不选`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-sel`,children:[(a||[]).map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,_.jsx)(`span`,{children:e.name})]},e.name)),a?.length?null:(0,_.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,_.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>y(e.target.checked)}),(0,_.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,_.jsxs)(`div`,{className:`form-acts`,children:[(0,_.jsx)(`button`,{className:`btn`,onClick:W,children:`生成布局`}),(0,_.jsx)(`button`,{className:`btn ghost`,disabled:!b,onClick:G,children:`下载 JSON`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`导出结果`})}),(0,_.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:b,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,_.jsxs)(`div`,{className:`rp-full-body`,children:[(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`导入来源`})}),(0,_.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:K}),(0,_.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:S,onChange:e=>{C(e.target.value),T(null)}}),(0,_.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,_.jsx)(`div`,{className:`form-acts`,children:(0,_.jsx)(`button`,{className:`btn`,disabled:!S.trim()||L,onClick:ne,children:`差异检查`})}),w?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,_.jsx)(`span`,{children:`冲突方案`})}),(0,_.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,_.jsx)(`input`,{type:`radio`,name:`strategy`,checked:A===e,onChange:()=>j(e)}),(0,_.jsx)(`span`,{children:t})]},e))}),(0,_.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,_.jsx)(`span`,{children:`克隆`})}),(0,_.jsxs)(`select`,{value:M,onChange:e=>ee(e.target.value),children:[(0,_.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,_.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,_.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,_.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,_.jsx)(`div`,{className:`form-acts`,children:(0,_.jsxs)(`button`,{className:`btn`,disabled:L,onClick:q,children:[`执行导入(已选 `,Object.values(E).filter(Boolean).length,`)`]})})]}):null,F?(0,_.jsxs)(`div`,{className:`rp-import-result`,children:[(0,_.jsxs)(`div`,{children:[`新建 `,F.created.length,` · 覆盖 `,F.updated.length,` · 另存 `,F.duplicated.length,` · 跳过 `,F.skipped.length]}),(0,_.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,F.boardsCreated,` / 合并 `,F.boardsMerged,` · 参考关系 `,F.links]}),F.cloned.length?(0,_.jsxs)(`div`,{children:[`克隆 `,F.cloned.length,` 个`]}):null,F.unmatched.length?(0,_.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,F.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,_.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:w?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,_.jsxs)(`span`,{children:[`差异(新增 `,oe.new,` · 有差异 `,oe.changed,` · 一致 `,oe.same,w.summary.missing?` · 本地未拥有 ${w.summary.missing}`:``,`)`]}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`rp-chip`+(N===``?` on`:``),onClick:()=>P(``),children:`全部`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`new`?` on`:``),onClick:()=>P(`new`),children:`新增`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`changed`?` on`:``),onClick:()=>P(`changed`),children:`有差异`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`same`?` on`:``),onClick:()=>P(`same`),children:`一致`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!0),children:`全选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!1),children:`全不选`})]})]}),(0,_.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,_.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{style:{width:`32px`}}),(0,_.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,_.jsx)(`th`,{children:`仓库 key`}),(0,_.jsx)(`th`,{children:`差异字段`})]})}),(0,_.jsxs)(`tbody`,{children:[re.map(e=>(0,_.jsxs)(`tr`,{className:`rp-diff-row `+v[e.status]?.cls,children:[(0,_.jsx)(`td`,{children:(0,_.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!E[e.key],onChange:t=>D(n=>({...n,[e.key]:t.target.checked}))})}),(0,_.jsx)(`td`,{children:(0,_.jsx)(`span`,{className:`rp-status `+v[e.status]?.cls,children:v[e.status]?.label})}),(0,_.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,_.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,_.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:L,onClick:()=>ie(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,_.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`b`,{children:e.field}),`: `,(0,_.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,_.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,_.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),w.missing.map(e=>(0,_.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,_.jsx)(`td`,{}),(0,_.jsx)(`td`,{children:(0,_.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,_.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,_.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),w.boards.length?(0,_.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`看板`})}),w.boards.map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!O[e.key],onChange:t=>k(n=>({...n,[e.key]:t.target.checked}))}),(0,_.jsx)(`span`,{className:`rp-status `+v[e.status]?.cls,children:v[e.status]?.label}),(0,_.jsx)(`span`,{children:e.key}),(0,_.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),w.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,_.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,_.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,_.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,_.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,_.jsx)(`button`,{className:`btn small`,disabled:L,onClick:()=>ie(e.key,e.remote),children:`克隆到本地`}):(0,_.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,_.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}function b(e){let t=String(e??``);return t.trim()?t.replace(/\{\{#[^}]*\}\}/g,``).replace(/\{\{\/[^}]*\}\}/g,``).replace(/\{\{[^}]*\}\}/g,``).replace(/「\s*」/g,``).replace(/〔\s*〕/g,``).replace(/\s+/g,` `).trim()||t.replace(/\s+/g,` `).trim():``}function x({value:e,onChange:t,placeholder:n,rows:r=3,hint:i=``}){return(0,_.jsxs)(`div`,{className:`pp-field`,children:[(0,_.jsx)(`textarea`,{className:`pp-field-ta mono`,rows:r,value:e,placeholder:n,spellCheck:!1,onChange:e=>t(e.target.value)}),i?(0,_.jsx)(`div`,{className:`pp-field-hint`,children:i}):null]})}function S({items:e,onChange:t,disabled:n=!1,placeholder:r,rows:i=3,accordion:a=!1,openIndex:o,onOpenChange:s}){let[c,l]=(0,g.useState)(-1),u=o===void 0?c:o,d=e=>{l(e),s&&s(e)},f=(n,r)=>t(e.map((e,t)=>t===n?r:e)),p=n=>{t(e.filter((e,t)=>t!==n)),d(e=>e===n?-1:e>n?e-1:e)};return a?(0,_.jsx)(`div`,{className:`pp-items`,children:e.map((e,t)=>{let a=u===t,o=b(e.split(`
2
- `)[0]);return(0,_.jsx)(`div`,{className:`pp-items-item`,children:a?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(x,{value:e,onChange:e=>f(t,e),placeholder:r,rows:i})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>p(t),title:`删除第 ${t+1} 条`,children:`删除`})]}):(0,_.jsxs)(`button`,{type:`button`,className:`pp-items-row`,disabled:n,title:`点击展开编辑`,onClick:()=>d(t),children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`span`,{className:`pp-items-title`,children:o||`(空)`}),(0,_.jsxs)(`span`,{className:`pp-items-len`,children:[String(e).length,` 字`]})]})},t)})}):(0,_.jsx)(_.Fragment,{children:e.map((e,t)=>(0,_.jsxs)(`div`,{className:`pp-items-item`,children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(x,{value:e,onChange:e=>f(t,e),placeholder:r,rows:i})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>p(t),title:`删除第 ${t+1} 条`,children:`删除`})]},t))})}var C=10,w=2e3,T=`不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get(带 --summary 当前现状)领取下一条任务,直到 get 返回 timeout 为止。`;function E({repo:e,onClose:t,onSaved:n}){let r=c()||{},s=o(),l=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[u,d]=(0,g.useState)(!!(l&&l.enabled)),[f,p]=(0,g.useState)(String(l&&l.waitMinutes||10)),[m,v]=(0,g.useState)(()=>{let e=l&&l.template;return(Array.isArray(e)?e:e==null?[]:[e]).map(e=>String(e??``).trim()).filter(Boolean).map(e=>e.replaceAll(`{{task.id}}`,`%s`))}),[y,b]=(0,g.useState)(-1),[x,E]=(0,g.useState)(``),[D,O]=(0,g.useState)(!1),k=async t=>{O(!0);try{let a=t&&t.enabled!==void 0?t.enabled:u,o=m.map(e=>String(e??``).trim().replaceAll(`%s`,`{{task.id}}`)).filter(Boolean).slice(0,C);await i(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{getLoop:{enabled:a,...a?{waitMinutes:Number(f)||10,template:o}:{}}}}),s(a?`已保存「${e.name}」的持续 get 设置(模板 ${o.length} 条)`:`已关闭「${e.name}」的持续 get`),r.refreshRepos&&r.refreshRepos(),n&&n()}catch(e){s(String(e.message||e))}finally{O(!1)}},A=async e=>{d(e),await k({enabled:e})},j=()=>{let e=x.trim();!e||m.length>=C||(v([...m,e.slice(0,w)]),b(m.length),E(``))};return(0,_.jsx)(a,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,_.jsxs)(`div`,{className:`rp-gl`,children:[(0,_.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,_.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,_.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,_.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,_.jsxs)(`button`,{className:`toggle`+(u?` on`:``),onClick:()=>A(!u),disabled:D,children:[(0,_.jsx)(`span`,{className:`dot`}),u?`开`:`关`]})]}),u&&(0,_.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,_.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,_.jsx)(`span`,{children:`阻塞窗口`}),(0,_.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,_.jsx)(`input`,{className:`rp-gl-min`,value:f,onChange:e=>p(e.target.value),inputMode:`numeric`}),`分钟`]})]}),(0,_.jsxs)(`div`,{className:`rp-gl-tpl`,children:[(0,_.jsx)(`div`,{className:`rp-gl-h`,children:`收尾模板`}),(0,_.jsxs)(`div`,{className:`rp-gl-oneline`,children:[(0,_.jsx)(h,{variant:`secondary`,title:`填入内置默认(继续 get 直到 timeout)`,onClick:()=>E(T),children:`填入内置默认`}),(0,_.jsx)(`input`,{className:`rp-gl-oneline-input`,value:x,placeholder:`一句话(%s = 任务编号)`,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j()}}),(0,_.jsx)(h,{variant:`secondary`,disabled:D||!x.trim(),onClick:j,children:`添加`})]}),m.length?(0,_.jsx)(S,{items:m,onChange:v,disabled:D,placeholder:`一句话(%s = 任务编号)`,accordion:!0,openIndex:y,onOpenChange:b}):(0,_.jsx)(`div`,{className:`rp-gl-note`,children:`未配置模板 —— 用默认「完成后续调 localtask get;没活时每轮最多阻塞 {{getloop.waitMinutes}} 分钟,直到 timeout」。`})]}),(0,_.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,_.jsx)(h,{variant:`secondary`,disabled:D||m.length>=C,title:m.length>=C?`最多 ${C} 条`:`新增一条「继续 get」指令`,onClick:()=>{v([...m,``]),b(m.length)},children:`添加一条…`}),(0,_.jsx)(`span`,{className:`spacer`}),(0,_.jsx)(h,{variant:`primary`,disabled:D,onClick:()=>k(),children:`保存持续 get 设置`})]})]})]})})}function D({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,_.jsx)(l,{text:t,children:t}):(0,_.jsxs)(l,{text:t,title:`点击复制完整路径`,children:[(0,_.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function O({docs:e,onOpen:t}){let n=e&&e.main,r=e&&e.links||[],i=+!!n+r.length,a=n&&n.exists?[n.title,n.summary&&`摘要:${n.summary}`].filter(Boolean).join(`
1
+ import{f as e,g as t,h as n,l as r,m as i,o as a,p as o,y as s}from"./task-status-BnymQMTw.js";import{n as c}from"./app-context-D7HAx67n.js";import{x as l}from"./index-DNB8tgNi.js";import{t as u}from"./route-crumb-BfRi1GKw.js";import{i as d,n as f}from"./Introduction-DAXj7E6q.js";import{t as p}from"./bar-KTPTE33i.js";import{t as m}from"./member-picker-BAgkj36N.js";import{t as h}from"./button-Cmo-6aoW.js";var g=s(t(),1),_=n(),v={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function y({onClose:t,onChanged:n,repos:r,boards:a}){let s=e(),c=o(),[l,u]=(0,g.useState)(`import`),[d,f]=(0,g.useState)({}),[p,m]=(0,g.useState)({}),[h,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(``),[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(null),[E,D]=(0,g.useState)({}),[O,k]=(0,g.useState)({}),[A,j]=(0,g.useState)(`ours`),[M,ee]=(0,g.useState)(`none`),[N,P]=(0,g.useState)(``),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(!1),z=(0,g.useMemo)(()=>r||[],[r]),B=(0,g.useMemo)(()=>z.map(e=>e.key),[z]),V=(0,g.useMemo)(()=>(a||[]).map(e=>e.name),[a]),H=e=>{let t={};for(let n of B)t[n]=e;f(t)},te=e=>{let t={};for(let n of V)t[n]=e;m(t)},U=()=>{let e={};for(let t of B)e[t]=!d[t];f(e)},W=()=>s(async()=>{let e=Object.keys(d).filter(e=>d[e]),t=Object.keys(p).filter(e=>p[e]),n={repos:e.length&&e.length!==B.length?e:void 0,boards:t.length&&t.length!==V.length?t.map(e=>`board/${e}`):void 0,noUnassigned:h},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),h&&r.set(`no-unassigned`,`1`);let a=await i(`/api/repos/export`+(r.toString()?`?`+r:``));x(JSON.stringify(a,null,2)),c(`已生成布局:${a.repos.length} 个仓库 / ${a.boards.length} 个看板`)}),G=()=>{if(!b)return;let e=new Blob([b],{type:`application/json`}),t=document.createElement(`a`);t.href=URL.createObjectURL(e),t.download=`nx-kv-layout-${new Date().toISOString().slice(0,10)}.json`,t.click(),URL.revokeObjectURL(t.href)},K=async e=>{let t=e.target.files?.[0];t&&(C(await t.text()),T(null),I(null))},ne=()=>s(async()=>{if(S.trim()){R(!0);try{let e=await i(`/api/repos/import/diff`,{method:`POST`,body:{json:S}});T(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;D(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;k(n),I(null),c(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{R(!1)}}}),q=()=>s(async()=>{let e=Object.keys(E).filter(e=>E[e]),t=Object.keys(O).filter(e=>O[e]);R(!0);try{let r=await i(`/api/repos/import`,{method:`POST`,body:{json:S,strategy:A,clone:M,selection:e.length?e:void 0,boards:t.length?t:void 0}});I(r),c(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await J(),n&&await n()}finally{R(!1)}}),J=(0,g.useCallback)(async()=>{try{let e=await i(`/api/repos/import/diff`,{method:`POST`,body:{json:S}});T(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;D(t)}catch{}},[S]),re=(0,g.useMemo)(()=>w?N?w.repos.filter(e=>e.status===N):w.repos:[],[w,N]),ie=(e,t)=>s(async()=>{if(t){R(!0);try{await i(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),c(`已克隆: ${e}`),await J(),n&&await n()}finally{R(!1)}}}),ae=e=>{let t={...E};for(let n of re)t[n.key]=e;D(t)};(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopImmediatePropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let oe=(0,g.useMemo)(()=>{if(!w)return null;let e={new:0,changed:0,same:0};for(let t of w.repos)e[t.status]=(e[t.status]||0)+1;return e},[w]);return(0,_.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,_.jsxs)(`div`,{className:`rp-full-box`,children:[(0,_.jsxs)(`div`,{className:`rp-full-head`,children:[(0,_.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,_.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,_.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,_.jsx)(`button`,{className:`rp-tab`+(l===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,_.jsx)(`button`,{className:`rp-tab`+(l===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),l===`export`?(0,_.jsxs)(`div`,{className:`rp-full-body`,children:[(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,_.jsx)(`span`,{children:`导出范围`}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>H(!0),children:`全选仓库`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>H(!1),children:`全不选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:U,children:`反选`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-sel`,children:[z.map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,_.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,_.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),z.length?null:(0,_.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,_.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,_.jsx)(`span`,{children:`看板`}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>te(!0),children:`全选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>te(!1),children:`全不选`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-sel`,children:[(a||[]).map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,_.jsx)(`span`,{children:e.name})]},e.name)),a?.length?null:(0,_.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,_.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>y(e.target.checked)}),(0,_.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,_.jsxs)(`div`,{className:`form-acts`,children:[(0,_.jsx)(`button`,{className:`btn`,onClick:W,children:`生成布局`}),(0,_.jsx)(`button`,{className:`btn ghost`,disabled:!b,onClick:G,children:`下载 JSON`})]})]}),(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`导出结果`})}),(0,_.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:b,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,_.jsxs)(`div`,{className:`rp-full-body`,children:[(0,_.jsxs)(`div`,{className:`rp-full-col`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`导入来源`})}),(0,_.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:K}),(0,_.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:S,onChange:e=>{C(e.target.value),T(null)}}),(0,_.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,_.jsx)(`div`,{className:`form-acts`,children:(0,_.jsx)(`button`,{className:`btn`,disabled:!S.trim()||L,onClick:ne,children:`差异检查`})}),w?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,_.jsx)(`span`,{children:`冲突方案`})}),(0,_.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,_.jsx)(`input`,{type:`radio`,name:`strategy`,checked:A===e,onChange:()=>j(e)}),(0,_.jsx)(`span`,{children:t})]},e))}),(0,_.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,_.jsx)(`span`,{children:`克隆`})}),(0,_.jsxs)(`select`,{value:M,onChange:e=>ee(e.target.value),children:[(0,_.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,_.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,_.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,_.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,_.jsx)(`div`,{className:`form-acts`,children:(0,_.jsxs)(`button`,{className:`btn`,disabled:L,onClick:q,children:[`执行导入(已选 `,Object.values(E).filter(Boolean).length,`)`]})})]}):null,F?(0,_.jsxs)(`div`,{className:`rp-import-result`,children:[(0,_.jsxs)(`div`,{children:[`新建 `,F.created.length,` · 覆盖 `,F.updated.length,` · 另存 `,F.duplicated.length,` · 跳过 `,F.skipped.length]}),(0,_.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,F.boardsCreated,` / 合并 `,F.boardsMerged,` · 参考关系 `,F.links]}),F.cloned.length?(0,_.jsxs)(`div`,{children:[`克隆 `,F.cloned.length,` 个`]}):null,F.unmatched.length?(0,_.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,F.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,_.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:w?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,_.jsxs)(`span`,{children:[`差异(新增 `,oe.new,` · 有差异 `,oe.changed,` · 一致 `,oe.same,w.summary.missing?` · 本地未拥有 ${w.summary.missing}`:``,`)`]}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(`button`,{className:`rp-chip`+(N===``?` on`:``),onClick:()=>P(``),children:`全部`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`new`?` on`:``),onClick:()=>P(`new`),children:`新增`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`changed`?` on`:``),onClick:()=>P(`changed`),children:`有差异`}),(0,_.jsx)(`button`,{className:`rp-chip`+(N===`same`?` on`:``),onClick:()=>P(`same`),children:`一致`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!0),children:`全选`}),(0,_.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!1),children:`全不选`})]})]}),(0,_.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,_.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{style:{width:`32px`}}),(0,_.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,_.jsx)(`th`,{children:`仓库 key`}),(0,_.jsx)(`th`,{children:`差异字段`})]})}),(0,_.jsxs)(`tbody`,{children:[re.map(e=>(0,_.jsxs)(`tr`,{className:`rp-diff-row `+v[e.status]?.cls,children:[(0,_.jsx)(`td`,{children:(0,_.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!E[e.key],onChange:t=>D(n=>({...n,[e.key]:t.target.checked}))})}),(0,_.jsx)(`td`,{children:(0,_.jsx)(`span`,{className:`rp-status `+v[e.status]?.cls,children:v[e.status]?.label})}),(0,_.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,_.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,_.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:L,onClick:()=>ie(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,_.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`b`,{children:e.field}),`: `,(0,_.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,_.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,_.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),w.missing.map(e=>(0,_.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,_.jsx)(`td`,{}),(0,_.jsx)(`td`,{children:(0,_.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,_.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,_.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),w.boards.length?(0,_.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,_.jsx)(`div`,{className:`rp-full-colhead`,children:(0,_.jsx)(`span`,{children:`看板`})}),w.boards.map(e=>(0,_.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!!O[e.key],onChange:t=>k(n=>({...n,[e.key]:t.target.checked}))}),(0,_.jsx)(`span`,{className:`rp-status `+v[e.status]?.cls,children:v[e.status]?.label}),(0,_.jsx)(`span`,{children:e.key}),(0,_.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),w.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,_.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,_.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,_.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,_.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,_.jsx)(`button`,{className:`btn small`,disabled:L,onClick:()=>ie(e.key,e.remote),children:`克隆到本地`}):(0,_.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,_.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}function b(e){let t=String(e??``);return t.trim()?t.replace(/\{\{#[^}]*\}\}/g,``).replace(/\{\{\/[^}]*\}\}/g,``).replace(/\{\{[^}]*\}\}/g,``).replace(/「\s*」/g,``).replace(/〔\s*〕/g,``).replace(/\s+/g,` `).trim()||t.replace(/\s+/g,` `).trim():``}function x({value:e,onChange:t,placeholder:n,rows:r=3,hint:i=``}){return(0,_.jsxs)(`div`,{className:`pp-field`,children:[(0,_.jsx)(`textarea`,{className:`pp-field-ta mono`,rows:r,value:e,placeholder:n,spellCheck:!1,onChange:e=>t(e.target.value)}),i?(0,_.jsx)(`div`,{className:`pp-field-hint`,children:i}):null]})}function S({items:e,onChange:t,disabled:n=!1,placeholder:r,rows:i=3,accordion:a=!1,openIndex:o,onOpenChange:s}){let[c,l]=(0,g.useState)(-1),u=o===void 0?c:o,d=e=>{l(e),s&&s(e)},f=(n,r)=>t(e.map((e,t)=>t===n?r:e)),p=n=>{t(e.filter((e,t)=>t!==n)),d(e=>e===n?-1:e>n?e-1:e)};return a?(0,_.jsx)(`div`,{className:`pp-items`,children:e.map((e,t)=>{let a=u===t,o=b(e.split(`
2
+ `)[0]);return(0,_.jsx)(`div`,{className:`pp-items-item`,children:a?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(x,{value:e,onChange:e=>f(t,e),placeholder:r,rows:i})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>p(t),title:`删除第 ${t+1} 条`,children:`删除`})]}):(0,_.jsxs)(`button`,{type:`button`,className:`pp-items-row`,disabled:n,title:`点击展开编辑`,onClick:()=>d(t),children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`span`,{className:`pp-items-title`,children:o||`(空)`}),(0,_.jsxs)(`span`,{className:`pp-items-len`,children:[String(e).length,` 字`]})]})},t)})}):(0,_.jsx)(_.Fragment,{children:e.map((e,t)=>(0,_.jsxs)(`div`,{className:`pp-items-item`,children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(x,{value:e,onChange:e=>f(t,e),placeholder:r,rows:i})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>p(t),title:`删除第 ${t+1} 条`,children:`删除`})]},t))})}var C=10,w=2e3,T=`不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get 领取下一条任务,直到 get 返回 timeout 为止。`;function E({repo:e,onClose:t,onSaved:n}){let r=c()||{},s=o(),l=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[u,d]=(0,g.useState)(!!(l&&l.enabled)),[f,p]=(0,g.useState)(String(l&&l.waitMinutes||10)),[m,v]=(0,g.useState)(()=>{let e=l&&l.template;return(Array.isArray(e)?e:e==null?[]:[e]).map(e=>String(e??``).trim()).filter(Boolean).map(e=>e.replaceAll(`{{task.id}}`,`%s`))}),[y,b]=(0,g.useState)(-1),[x,E]=(0,g.useState)(``),[D,O]=(0,g.useState)(!1),k=async t=>{O(!0);try{let a=t&&t.enabled!==void 0?t.enabled:u,o=m.map(e=>String(e??``).trim().replaceAll(`%s`,`{{task.id}}`)).filter(Boolean).slice(0,C);await i(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{getLoop:{enabled:a,...a?{waitMinutes:Number(f)||10,template:o}:{}}}}),s(a?`已保存「${e.name}」的持续 get 设置(模板 ${o.length} 条)`:`已关闭「${e.name}」的持续 get`),r.refreshRepos&&r.refreshRepos(),n&&n()}catch(e){s(String(e.message||e))}finally{O(!1)}},A=async e=>{d(e),await k({enabled:e})},j=()=>{let e=x.trim();!e||m.length>=C||(v([...m,e.slice(0,w)]),b(m.length),E(``))};return(0,_.jsx)(a,{title:`持续 get · ${e.name}`,onClose:t,size:`md`,children:(0,_.jsxs)(`div`,{className:`rp-gl`,children:[(0,_.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,_.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,_.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,_.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,_.jsxs)(`button`,{className:`toggle`+(u?` on`:``),onClick:()=>A(!u),disabled:D,children:[(0,_.jsx)(`span`,{className:`dot`}),u?`开`:`关`]})]}),u&&(0,_.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,_.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,_.jsx)(`span`,{children:`阻塞窗口`}),(0,_.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,_.jsx)(`input`,{className:`rp-gl-min`,value:f,onChange:e=>p(e.target.value),inputMode:`numeric`}),`分钟`]})]}),(0,_.jsxs)(`div`,{className:`rp-gl-tpl`,children:[(0,_.jsx)(`div`,{className:`rp-gl-h`,children:`收尾模板`}),(0,_.jsxs)(`div`,{className:`rp-gl-oneline`,children:[(0,_.jsx)(h,{variant:`secondary`,title:`填入内置默认(继续 get 直到 timeout)`,onClick:()=>E(T),children:`填入内置默认`}),(0,_.jsx)(`input`,{className:`rp-gl-oneline-input`,value:x,placeholder:`一句话(%s = 任务编号)`,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&j()}}),(0,_.jsx)(h,{variant:`secondary`,disabled:D||!x.trim(),onClick:j,children:`添加`})]}),m.length?(0,_.jsx)(S,{items:m,onChange:v,disabled:D,placeholder:`一句话(%s = 任务编号)`,accordion:!0,openIndex:y,onOpenChange:b}):(0,_.jsx)(`div`,{className:`rp-gl-note`,children:`未配置模板 —— 用默认「完成后续调 localtask get;没活时每轮最多阻塞 {{getloop.waitMinutes}} 分钟,直到 timeout」。`})]}),(0,_.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,_.jsx)(h,{variant:`secondary`,disabled:D||m.length>=C,title:m.length>=C?`最多 ${C} 条`:`新增一条「继续 get」指令`,onClick:()=>{v([...m,``]),b(m.length)},children:`添加一条…`}),(0,_.jsx)(`span`,{className:`spacer`}),(0,_.jsx)(h,{variant:`primary`,disabled:D,onClick:()=>k(),children:`保存持续 get 设置`})]})]})]})})}function D({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,_.jsx)(l,{text:t,children:t}):(0,_.jsxs)(l,{text:t,title:`点击复制完整路径`,children:[(0,_.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function O({docs:e,onOpen:t}){let n=e&&e.main,r=e&&e.links||[],i=+!!n+r.length,a=n&&n.exists?[n.title,n.summary&&`摘要:${n.summary}`].filter(Boolean).join(`
3
3
  `):`查看完整文档列表(主篇 / 补充 / reference / 组内),可就地编辑`;return(0,_.jsxs)(`button`,{type:`button`,className:`rp-docs-entry`,title:a,onClick:t,children:[(0,_.jsx)(`span`,{className:`rp-docs-entry-main`+(n&&n.exists?``:` ghost`),children:n&&n.exists?n.title||n.summary||`未命名`:`+ 写项目介绍`}),(0,_.jsx)(`span`,{className:`rp-docs-entry-n`,children:i>0?`${i} 篇 · 查看详情`:`查看详情`})]})}function k({chips:e,boardId:t,acts:n}){let[r,i]=(0,g.useState)(!1),a=r?e:e.slice(0,4);return(0,_.jsxs)(_.Fragment,{children:[a.map(e=>(0,_.jsx)(`span`,{className:`rp-link-chip rp-link-chip-`+(e.source===`group`?`group`:`repo`),children:(0,_.jsxs)(`button`,{className:`rp-link-chip-main`,title:e.source===`group`?[`组「${e.groupName}」共享的参考仓库`,e.note].filter(Boolean).join(`
4
4
  `):[`本仓库直接绑定的参考仓库`,e.note,`点击跳到这个参考仓库`].filter(Boolean).join(`
5
5
  `),onClick:()=>e.source===`group`?n.keepFilter(t):n.gotoRefRepo(e.key),children:[(0,_.jsx)(`b`,{children:e.source===`group`?`组`:`自`}),(0,_.jsx)(`span`,{className:`rp-link-chip-name`,children:e.name})]})},e.source+`:`+e.key)),e.length>4?(0,_.jsx)(`button`,{className:`rp-bind-more`,title:`展开本行全部参考仓库`,onClick:()=>i(e=>!e),children:r?`收起`:`+${e.length-4}`}):null]})}function A({r:e,filterBoard:t,groupRefRepoCounts:n,refRepoChipsByRepo:r,acts:i}){let a=n.get(e.key)||[],o=t?r.get(e.key)||[]:null;return(0,_.jsxs)(`tr`,{id:`rp-row-`+e.key,children:[(0,_.jsxs)(`td`,{className:`rp-name`,children:[(0,_.jsxs)(`strong`,{children:[e.icon?(0,_.jsx)(`span`,{className:`rp-icon`,"aria-hidden":!0,children:e.icon}):null,e.name,e.getLoop&&e.getLoop.enabled?(0,_.jsx)(`span`,{className:`rp-gl-dot`,title:`持续 get 已开启(${Number(e.getLoop.waitMinutes)||10} 分钟阻塞窗口)`,"aria-label":`持续 get 已开启`}):null]}),(0,_.jsx)(`span`,{className:`mono rp-name-path`,children:(0,_.jsx)(D,{path:e.path})})]}),(0,_.jsx)(`td`,{className:`rp-cell-docs`,children:(0,_.jsx)(O,{docs:e.descDocs,onOpen:()=>i.docs(e)})}),(0,_.jsxs)(`td`,{className:`rp-refs`,children:[t?o&&o.length?(0,_.jsx)(k,{chips:o,boardId:t.id,acts:i}):(0,_.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}):a.length?a.map(e=>(0,_.jsxs)(`button`,{className:`rp-group-chip`+(t&&t.id===e.id?` on`:``),title:`组「${e.name}」绑定 ${e.count} 个参考仓库(组内共享)\n点击只看这个组`,onClick:()=>i.filter(e.id),children:[e.name,` `,(0,_.jsx)(`b`,{children:e.count})]},e.id)):(0,_.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}),(0,_.jsx)(h,{small:!0,className:`rp-ref-bind`,title:`管理这个仓库所属组的参考仓库`,onClick:()=>i.bind(e),children:`绑定`})]}),(0,_.jsx)(`td`,{className:`rp-cell-groups`,children:(e.boards||[]).length?e.boards.map(e=>(0,_.jsx)(`button`,{className:`rp-group-chip`+(t&&t.id===e.id?` on`:``),title:`只看「${e.name}」${e.note?`\n组内描述:${e.note}`:``}`,onClick:()=>i.filter(e.id),children:e.name},e.id)):(0,_.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`})}),(0,_.jsx)(`td`,{className:`rp-acts`,children:(0,_.jsx)(p,{kind:`repos-row`,renderers:{edit:()=>(0,_.jsx)(h,{small:!0,onClick:()=>i.edit(e),children:`编辑`}),open:()=>(0,_.jsx)(h,{small:!0,title:`在文件管理器中打开`,onClick:()=>i.open(e),children:`打开`}),del:()=>(0,_.jsx)(h,{small:!0,danger:!0,onClick:()=>i.del(e),children:`删除`}),getloop:()=>(0,_.jsx)(h,{small:!0,title:`持续 get(waitgoal)配置`,onClick:()=>i.getloop(e),children:(0,_.jsxs)(`span`,{className:`rp-gl-menu-it`,children:[e.getLoop&&e.getLoop.enabled?(0,_.jsx)(`span`,{className:`rp-gl-dot`,"aria-hidden":!0}):null,`持续 get…`]})}),remote:()=>(0,_.jsx)(h,{small:!0,onClick:()=>i.remote(e),children:`对齐 remote`})},actions:{edit:()=>i.edit(e),open:()=>i.open(e),del:()=>i.del(e),getloop:()=>i.getloop(e),remote:()=>i.remote(e)},titles:{getloop:`持续 get(waitgoal)配置`,remote:`key 与远程 git 地址对齐`,del:`删除仓库登记(磁盘文件不受影响)`}})})]})}function j({shown:e,devRepos:t,filterBoard:n,groupRefRepoCounts:r,refRepoChipsByRepo:i,acts:a,onAddMember:o}){return(0,_.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-repos`,children:(0,_.jsxs)(`table`,{className:`rp-table`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{scope:`col`,style:{width:`16%`},children:`仓库`}),(0,_.jsxs)(`th`,{scope:`col`,style:{width:`36%`},children:[`文档`,(0,_.jsx)(`span`,{className:`rp-th-hint`,children:`主篇标题 · 查看详情打开完整文档列表`})]}),(0,_.jsx)(`th`,{scope:`col`,style:{width:`18%`},children:`参考仓库`}),(0,_.jsx)(`th`,{scope:`col`,style:{width:`14%`},children:`分组`}),(0,_.jsx)(`th`,{scope:`col`,style:{width:`250px`},children:`操作`})]})}),(0,_.jsxs)(`tbody`,{children:[e.map(e=>(0,_.jsx)(A,{r:e,filterBoard:n,groupRefRepoCounts:r,refRepoChipsByRepo:i,acts:a},e.id)),e.length?null:(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:`5`,className:`muted rp-empty`,children:t.length?(0,_.jsxs)(_.Fragment,{children:[`这个分组还没有成员`,` `,n?(0,_.jsx)(h,{small:!0,onClick:()=>o(n.id),children:`添加成员`}):null]}):`还没有登记开发仓库 —— 点右上「登记仓库」加一条。`})})]})]})})}function M({boards:e,filter:t,onFilter:n,devCount:r,shownCount:i,q:a,onQ:o,onOpenDocs:s}){return(0,_.jsxs)(`div`,{className:`rp-filters`,"data-testid":`rp-filters`,children:[(0,_.jsxs)(`div`,{className:`rp-filters-main`,children:[(0,_.jsxs)(`button`,{className:`rp-chip`+(t?``:` on`),onClick:()=>n(``),title:`显示全部开发仓库`,children:[`全部 `,(0,_.jsx)(`b`,{children:r})]}),e.map(e=>(0,_.jsxs)(`button`,{className:`rp-chip`+(t===e.id?` on`:``),onClick:()=>n(t===e.id?``:e.id),title:`只看「${e.name}」里的仓库(${e.repos.length} 个)`,children:[e.name,` `,(0,_.jsx)(`b`,{children:e.repos.length})]},e.id))]}),(0,_.jsxs)(`div`,{className:`rp-filters-side`,children:[(0,_.jsx)(`input`,{className:`rp-search`,type:`search`,value:a,onChange:e=>o(e.target.value),placeholder:`搜仓库 / 路径 / 分组 / 文档…`,"aria-label":`检索仓库与文档`}),a?(0,_.jsx)(h,{small:!0,onClick:()=>o(``),children:`清空`}):null,(0,_.jsxs)(`span`,{className:`muted rp-search-count`,children:[i,` / `,r]}),(0,_.jsx)(h,{small:!0,title:`按仓库 / 组内 / 分组三档检索文档`,onClick:s,children:`文档检索`})]})]})}function ee({filterBoard:e,refRepos:t,checkOf:n,onOpenDoc:r,onAddMember:i,onSync:a,onOpen:o,onLinkNote:s,onUnbind:c}){let u=(0,g.useMemo)(()=>{if(!e)return[];let n=new Map(t.map(e=>[e.key,e]));return(e.refs||[]).map(e=>{let t=n.get(e.id);return t?{...t,boardNote:e.note||``}:null}).filter(Boolean)},[t,e]),[d,f]=(0,g.useState)(null);(0,g.useEffect)(()=>{f(null)},[e?e.id:null]);let p=d===null?u.length<=8:d;return e?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`rp-context`,"data-testid":`rp-context`,children:[(0,_.jsx)(`span`,{className:`rp-context-name`,children:e.name}),e.desc?(0,_.jsx)(`span`,{className:`rp-context-desc`,title:e.desc,children:e.desc}):(0,_.jsx)(`span`,{className:`muted rp-context-desc`,children:`还没有领域描述 —— 点「组介绍文档」补一段:侧重什么、谁配合谁、关键路径与搜索关键词在哪。`}),(0,_.jsxs)(`span`,{className:`acts`,children:[(0,_.jsx)(h,{small:!0,title:`打开这个分组的组介绍文档`,onClick:()=>r(e),children:`组介绍文档 ✎`}),(0,_.jsx)(`a`,{className:`btn small ghost`,href:`#/group/`+encodeURIComponent(e.id),title:`组页里看这个组的成员与任务`,children:`组页 ↗`}),(0,_.jsx)(h,{small:!0,onClick:()=>i(e.id),children:`添加成员`})]})]}),(0,_.jsxs)(`div`,{className:`rp-ref-mounted`,"data-testid":`rp-board-refs`,children:[(0,_.jsxs)(`div`,{className:`rp-ref-mounted-head`,children:[(0,_.jsxs)(`span`,{className:`rp-ref-mounted-label`,children:[`「`,e.name,`」的参考仓库 `,(0,_.jsx)(`b`,{children:u.length})]}),(0,_.jsx)(`span`,{className:`muted`,children:`绑定在组上:组内所有仓库共享,不区分来源仓库`}),u.length?(0,_.jsx)(h,{small:!0,className:`rp-ref-mounted-toggle`,title:p?`收起这个组的参考仓库清单`:`展开这个组的参考仓库清单`,onClick:()=>f(!p),children:p?`收起`:`展开 ${u.length}`}):null]}),u.length?p?u.map(t=>{let r=n.get(t.id);return(0,_.jsxs)(`div`,{className:`rp-ref-mounted-item`,children:[(0,_.jsx)(`span`,{className:`rp-ref-dot`+(r?r.ok?` ok`:` bad`:``),title:r?r.ok?`检查通过`:r.issues.join(`
@@ -1 +1 @@
1
- import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{n as r}from"./app-context-D7HAx67n.js";import{n as i}from"./board-view-CZKZsyk-.js";import{t as a}from"./index-BrAIkzFc.js";var o=n(e(),1);function s(e,t={}){if(!e||!e.view)return[];switch(e.view){case`dir`:{let n=[];return t.dirName&&n.push(t.dirName),e.task&&(/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`)),n}case`group`:if(e.task){let n=[t.boardName||`项目组`];return/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`),n}return t.boardName?[t.boardName]:[`项目组`];case`repos`:return[`仓库管理`];case`cloud`:return[`云端总览`];case`overview`:return[`全部目录总览`];case`templates`:return e.mode===`new`?[`新建模板`]:e.mode===`edit`?[`编辑模板`]:[`任务模板`];case`doc`:{let e=t.repoName||t.boardName||``;return e?[e]:[`文档`]}default:return[]}}function c(e){if(!e||!e.view)return``;switch(e.view){case`dir`:return e.task?`#/dir/${encodeURIComponent(e.key||``)}`:`#/overview`;case`group`:return e.task?`#/group/${encodeURIComponent(e.key||``)}`:`#/overview`;case`overview`:return``;case`doc`:return e.repoKey?`#/repos`:e.boardKey?`#/group/${encodeURIComponent(e.boardKey)}`:`#/repos`;default:return`#/overview`}}function l(e,t=[],n={}){if(!e)return{boardName:``,dirName:``,pageTitle:``};let r=(n.boards||[]).find(t=>t.id===e.key);if(e.view===`group`&&e.task){let a=i(t,n.boards||[],e.key,e.task);return{boardName:a.board&&a.board.name||r&&r.name||``,dirName:a.topic?a.topic.name:``,pageTitle:a.taskRow?`#${a.taskRow.id}`:``}}let a=(t||[]).find(t=>t.key===e.key),o=a&&e.task?(a.tasks||[]).find(t=>String(t.id)===String(e.task)):null;if(e.view===`doc`){let t=(n.repos||[]).find(t=>t.key===e.repoKey),r=(n.boards||[]).find(t=>t.id===e.boardKey||t.key===e.boardKey);return{boardName:e.boardName||r&&r.name||``,dirName:``,pageTitle:``,repoName:t&&t.name||``}}return{boardName:r&&r.name||``,dirName:a?a.name:``,pageTitle:o?`#${o.id}`:``}}var u=t();function d({route:e,ctx:t,onNavigate:n,onBack:r,inline:i=!1}){let a=(0,o.useMemo)(()=>s(e,t),[e,t]),l=(0,o.useMemo)(()=>c(e,t),[e,t]);if(!a.length)return null;let d=`nx-crumb`+(i?` nx-crumb-inline`:``),f=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`[`}),a.map((e,t)=>(0,u.jsxs)(`span`,{className:`nx-crumb-i`,children:[t>0?(0,u.jsx)(`span`,{className:`nx-crumb-sep`,children:`/`}):null,(0,u.jsx)(`span`,{className:`nx-crumb-t`,children:e})]},`${e}-${t}`)),(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`]`})]});return l&&n?(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:(0,u.jsx)(`button`,{type:`button`,className:`nx-crumb-path`,title:`返回上一级`,"aria-label":`返回上一级(${a.join(` / `)})`,onClick:()=>r?r():n(l),children:f})}):(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:f})}function f(){let e=r()||{},t=e.route||{},n=e.rows||[],i=e.repoData||{},f=(0,o.useMemo)(()=>l(t,n,i),[t,n,i]);return(0,o.useMemo)(()=>s(t,f),[t,f]).length?(0,u.jsx)(d,{route:t,ctx:f,onNavigate:e.onNavigate,onBack:()=>{let n=a();if(n&&e.onNavigate){e.onNavigate(n);return}let r=c(t,f);r&&e.onNavigate&&e.onNavigate(r)},inline:!0}):null}export{f as t};
1
+ import{g as e,h as t,y as n}from"./task-status-BnymQMTw.js";import{n as r}from"./app-context-D7HAx67n.js";import{n as i}from"./board-view-CZKZsyk-.js";import{t as a}from"./index-DNB8tgNi.js";var o=n(e(),1);function s(e,t={}){if(!e||!e.view)return[];switch(e.view){case`dir`:{let n=[];return t.dirName&&n.push(t.dirName),e.task&&(/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`)),n}case`group`:if(e.task){let n=[t.boardName||`项目组`];return/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`),n}return t.boardName?[t.boardName]:[`项目组`];case`repos`:return[`仓库管理`];case`cloud`:return[`云端总览`];case`overview`:return[`全部目录总览`];case`templates`:return e.mode===`new`?[`新建模板`]:e.mode===`edit`?[`编辑模板`]:[`任务模板`];case`doc`:{let e=t.repoName||t.boardName||``;return e?[e]:[`文档`]}default:return[]}}function c(e){if(!e||!e.view)return``;switch(e.view){case`dir`:return e.task?`#/dir/${encodeURIComponent(e.key||``)}`:`#/overview`;case`group`:return e.task?`#/group/${encodeURIComponent(e.key||``)}`:`#/overview`;case`overview`:return``;case`doc`:return e.repoKey?`#/repos`:e.boardKey?`#/group/${encodeURIComponent(e.boardKey)}`:`#/repos`;default:return`#/overview`}}function l(e,t=[],n={}){if(!e)return{boardName:``,dirName:``,pageTitle:``};let r=(n.boards||[]).find(t=>t.id===e.key);if(e.view===`group`&&e.task){let a=i(t,n.boards||[],e.key,e.task);return{boardName:a.board&&a.board.name||r&&r.name||``,dirName:a.topic?a.topic.name:``,pageTitle:a.taskRow?`#${a.taskRow.id}`:``}}let a=(t||[]).find(t=>t.key===e.key),o=a&&e.task?(a.tasks||[]).find(t=>String(t.id)===String(e.task)):null;if(e.view===`doc`){let t=(n.repos||[]).find(t=>t.key===e.repoKey),r=(n.boards||[]).find(t=>t.id===e.boardKey||t.key===e.boardKey);return{boardName:e.boardName||r&&r.name||``,dirName:``,pageTitle:``,repoName:t&&t.name||``}}return{boardName:r&&r.name||``,dirName:a?a.name:``,pageTitle:o?`#${o.id}`:``}}var u=t();function d({route:e,ctx:t,onNavigate:n,onBack:r,inline:i=!1}){let a=(0,o.useMemo)(()=>s(e,t),[e,t]),l=(0,o.useMemo)(()=>c(e,t),[e,t]);if(!a.length)return null;let d=`nx-crumb`+(i?` nx-crumb-inline`:``),f=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`[`}),a.map((e,t)=>(0,u.jsxs)(`span`,{className:`nx-crumb-i`,children:[t>0?(0,u.jsx)(`span`,{className:`nx-crumb-sep`,children:`/`}):null,(0,u.jsx)(`span`,{className:`nx-crumb-t`,children:e})]},`${e}-${t}`)),(0,u.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`]`})]});return l&&n?(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:(0,u.jsx)(`button`,{type:`button`,className:`nx-crumb-path`,title:`返回上一级`,"aria-label":`返回上一级(${a.join(` / `)})`,onClick:()=>r?r():n(l),children:f})}):(0,u.jsx)(`nav`,{className:d,"aria-label":`当前位置`,children:f})}function f(){let e=r()||{},t=e.route||{},n=e.rows||[],i=e.repoData||{},f=(0,o.useMemo)(()=>l(t,n,i),[t,n,i]);return(0,o.useMemo)(()=>s(t,f),[t,f]).length?(0,u.jsx)(d,{route:t,ctx:f,onNavigate:e.onNavigate,onBack:()=>{let n=a();if(n&&e.onNavigate){e.onNavigate(n);return}let r=c(t,f);r&&e.onNavigate&&e.onNavigate(r)},inline:!0}):null}export{f as t};
@@ -1,4 +1,4 @@
1
- import{g as e,h as t,l as n,m as r,p as i,u as a,y as o}from"./task-status-BnymQMTw.js";import{n as s}from"./app-context-D7HAx67n.js";import{n as c,o as l}from"./index-BrAIkzFc.js";import{t as u}from"./button-Cmo-6aoW.js";var d=o(e(),1),f=Object.freeze([{id:`xml`,label:`XML 区块(默认)`,desc:`每段系统内容包进独立标签,agent 一眼分清任务原文与系统规则`},{id:`plain`,label:`正文直追加`,desc:`不包标签,按空行拼接(与改造前的 instruction 逐字一致)`}]),p=8e3,m=`builtin`,h=`系统内置`,g=`{{#if repo}},{{#if repo.intro}},〔项目介绍 · {{repo.name}}〕({{repo.introPath}}):,{{repo.intro}},{{/if}},{{#if repo.docs}},项目补充文档(可直接读取):,{{#each repo.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}},{{#if group}},〔项目组上下文 · {{group.name}}〕,{{#if group.desc}},组定位:{{group.desc}},{{/if}},{{#if group.intro}},组介绍({{group.introPath}}):,{{group.intro}},{{/if}},{{#if group.note}},本项目在组里的位置:{{group.note}},{{/if}},{{#if group.peers}},组内成员:,{{#each group.peers}}, - {{name}}:{{#if note}}{{note}}{{else}}(无组内描述){{/if}}{{#if path}}({{path}}){{/if}},{{/each}},{{/if}},{{#if group.docs}},组绑定参考文件(可直接读取):,{{#each group.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}},{{#if refRepos.count}},参考仓库(可直接读取,共 {{refRepos.count}} 个):,{{#each refRepos.list}}, - {{name}}{{#if path}}({{path}}){{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}}`.split(`,`).join(`
1
+ import{g as e,h as t,l as n,m as r,p as i,u as a,y as o}from"./task-status-BnymQMTw.js";import{n as s}from"./app-context-D7HAx67n.js";import{n as c,o as l}from"./index-DNB8tgNi.js";import{t as u}from"./button-Cmo-6aoW.js";var d=o(e(),1),f=Object.freeze([{id:`xml`,label:`XML 区块(默认)`,desc:`每段系统内容包进独立标签,agent 一眼分清任务原文与系统规则`},{id:`plain`,label:`正文直追加`,desc:`不包标签,按空行拼接(与改造前的 instruction 逐字一致)`}]),p=8e3,m=`builtin`,h=`系统内置`,g=`{{#if repo}},{{#if repo.intro}},〔项目介绍 · {{repo.name}}〕({{repo.introPath}}):,{{repo.intro}},{{/if}},{{#if repo.docs}},项目补充文档(可直接读取):,{{#each repo.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}},{{#if group}},〔项目组上下文 · {{group.name}}〕,{{#if group.desc}},组定位:{{group.desc}},{{/if}},{{#if group.intro}},组介绍({{group.introPath}}):,{{group.intro}},{{/if}},{{#if group.note}},本项目在组里的位置:{{group.note}},{{/if}},{{#if group.peers}},组内成员:,{{#each group.peers}}, - {{name}}:{{#if note}}{{note}}{{else}}(无组内描述){{/if}}{{#if path}}({{path}}){{/if}},{{/each}},{{/if}},{{#if group.docs}},组绑定参考文件(可直接读取):,{{#each group.docs}}, - {{path}}{{#if tag}} [{{tag}}]{{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}},{{/if}},{{#if refRepos.count}},参考仓库(可直接读取,共 {{refRepos.count}} 个):,{{#each refRepos.list}}, - {{name}}{{#if path}}({{path}}){{/if}}{{#if note}} # {{note}}{{/if}},{{/each}},{{/if}}`.split(`,`).join(`
2
2
  `),_=[`{{#if attach}}`,`〔附件〕本任务包含 {{attach.count}} 个附件(正文内嵌 {{attach.inlineCount}} · 附件区 {{attach.areaCount}})。请先识别附件内容(图片先看图、文档先读内容)再开始处理,不要跳过附件。`,``,`附件清单:`,`{{#each attach.list}}`,` - [{{originLabel}}] {{kindLabel}} {{name}}{{#if sizeText}}({{sizeText}}){{/if}}:{{#if file}}{{#if file.exists}}{{file.localPath}}{{else}}未同步到本地(fileId {{file.fileId}}){{/if}}{{/if}}{{#if url}}{{url.href}}{{/if}}{{#if task}}{{#if task.resolved}}#{{task.seq}} {{task.title}} · 地址 {{task.address}}({{task.statusLabel}}){{else}}地址 {{task.address}}({{task.statusLabel}}){{/if}}{{/if}}{{#if ref}}{{ref.title}}{{#if ref.relPath}}({{ref.relPath}}){{/if}}{{/if}}{{#if note}} # {{note}}{{/if}}`,`{{/each}}`,``,`取用方式:`,`{{#each attach.list}}`,` - {{kindLabel}} 《{{name}}》:{{usage}}`,`{{/each}}`,`{{#if attach.syncSummary}}`,`同步情况:{{attach.syncSummary.text}}`,`{{/if}}`,`{{#each attach.list}}{{#if ref}}{{#if ref.content}}〔文档原文 · {{ref.title}}〕({{ref.relPath}}):`,``,`{{ref.content}}`,``,`{{/if}}{{/if}}{{/each}}`,`{{/if}}`].join(`
3
3
  `),v=[`{{#if goal.check}}`,`{{goal.check}}`,`{{/if}}`,`{{#if goal.statusLine}}`,`{{goal.statusLine}}`,`{{/if}}`].join(`
4
4
  `),y=[`{{#if ext.count}}`,`本队列({{ext.topic}})还有 {{ext.count}} 条待领取任务:`,`{{#each ext.list}}`,` - #{{id}} {{title}}`,`{{/each}}`,`先完成当前任务,再领取下一条;不要因为后面还有活就提前收尾或分心。`,`{{/if}}`].join(`
@@ -1 +1 @@
1
- import{h as e}from"./task-status-BnymQMTw.js";import{b as t,v as n,y as r}from"./index-BrAIkzFc.js";var i=e();function a({t:e,short:a=!1,className:o=``,title:s}){let c=t(e);return(0,i.jsx)(`span`,{className:`tstat tstat-`+c+(a?` tstat-short`:``)+(o?` `+o:``),title:s||(a?n(e):void 0),children:a?r(e):n(e)})}export{a as t};
1
+ import{h as e}from"./task-status-BnymQMTw.js";import{b as t,v as n,y as r}from"./index-DNB8tgNi.js";var i=e();function a({t:e,short:a=!1,className:o=``,title:s}){let c=t(e);return(0,i.jsx)(`span`,{className:`tstat tstat-`+c+(a?` tstat-short`:``)+(o?` `+o:``),title:s||(a?n(e):void 0),children:a?r(e):n(e)})}export{a as t};
@@ -1,4 +1,4 @@
1
- import{g as e,h as t,l as n,m as r,o as i,p as a,u as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,t as l,v as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{n as f,r as p,t as m}from"./frontmatter-QvrjUNzF.js";import{a as h,g,h as _,i as v,m as y,n as b,p as x,r as S,t as C,u as w,v as T}from"./md-history-DB5forf2.js";import{a as E,r as D}from"./md-parse-awNLHAzO.js";import{n as O,t as k}from"./board-view-CZKZsyk-.js";import{c as A,d as j,f as M,h as N,l as P,m as F,p as I,s as L,u as R}from"./index-BrAIkzFc.js";import{t as z}from"./status-tag-BoUoKYZK.js";import{a as B,i as V,n as ee,o as H}from"./composer-launch-Bf4rXhLs.js";import{t as te}from"./route-crumb-C8JzPIax.js";import{i as ne,n as U,r as W,t as G}from"./reopen-text-BylkngqC.js";import{n as re,u as K}from"./tool-bar-DGCwnUcn.js";var q=s(e(),1),J=/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/,Y=/完成总结/,ie=/反馈/,ae=/第\s*(\d+)\s*轮/;function oe(e){let t=String(e??``).split(`
1
+ import{g as e,h as t,l as n,m as r,o as i,p as a,u as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,t as l,v as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{n as f,r as p,t as m}from"./frontmatter-QvrjUNzF.js";import{a as h,g,h as _,i as v,m as y,n as b,p as x,r as S,t as C,u as w,v as T}from"./md-history-C9vOgGLz.js";import{a as E,r as D}from"./md-parse-awNLHAzO.js";import{n as O,t as k}from"./board-view-CZKZsyk-.js";import{c as A,d as j,f as M,h as N,l as P,m as F,p as I,s as L,u as R}from"./index-DNB8tgNi.js";import{t as z}from"./status-tag-p3fo3Hbr.js";import{a as B,i as V,n as ee,o as H}from"./composer-launch-Bf4rXhLs.js";import{t as te}from"./route-crumb-BfRi1GKw.js";import{i as ne,n as U,r as W,t as G}from"./reopen-text-BylkngqC.js";import{n as re,u as K}from"./tool-bar-DpwpQ47h.js";var q=s(e(),1),J=/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/,Y=/完成总结/,ie=/反馈/,ae=/第\s*(\d+)\s*轮/;function oe(e){let t=String(e??``).split(`
2
2
  `),n=t.length&&String(t[0]).match(J);if(!n)return null;let r=t.slice(1).map(e=>e.replace(/^>[ \t]?/,``)).filter(e=>e.trim()!==``).join(`
3
3
  `);return{title:String(n[1]??``).trim(),body:r}}function se(e){let t=y(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim(),o=oe(a);if(o&&Y.test(o.title)){let e=Number((o.title.match(ae)||[])[1]);r={round:Number.isFinite(e)&&e>0?e:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:o.body,feedbackText:``},n.push(r),i=`ack`;return}if(a===`## 上一轮完成总结`){r={round:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:``,feedbackText:``},n.push(r),i=`ack`;return}if(o&&ie.test(o.title)){r&&i===`ack`&&(r.feedbackBlockIndex=t,r.feedbackText=o.body,i=`feedback`);return}if(a===`## 验收反馈`){r&&i===`ack`&&(r.feedbackBlockIndex=t,i=`feedback`);return}a&&r&&(i===`ack`?r.ackText+=(r.ackText?`
4
4
  `:``)+a:r.feedbackText+=(r.feedbackText?`
@@ -6,6 +6,6 @@ import{g as e,h as t,l as n,m as r,o as i,p as a,u as o,y as s}from"./task-statu
6
6
  `).map(e=>e.replace(/^#+\s*/,``).replace(/\*\*/g,``).trim()).find(e=>e!==``);if(!t)return`第 ${e?.round??1} 轮`;let n=t.length>24?`${t.slice(0,24)}…`:t;return`第 ${e.round} 轮 · ${n}`}var le=`nx-kv-ack-rail-pos`;function ue(e={}){let{x:t,y:n,parentW:r,parentH:i,railW:a=0,railH:o=0,margin:s=8}=e||{};if(![t,n,r,i].every(e=>Number.isFinite(e)))return null;let c=Math.max(s,r-a-s),l=Math.max(s,i-o-s);return{x:Math.min(c,Math.max(s,t)),y:Math.min(l,Math.max(s,n))}}function de(){try{let e=JSON.parse(localStorage.getItem(le)||`null`);if(!e||typeof e!=`object`)return null;let t=Number(e.x),n=Number(e.y);return!Number.isFinite(t)||!Number.isFinite(n)?null:{x:t,y:n}}catch{return null}}function fe(e){try{e?localStorage.setItem(le,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(le)}catch{}}var X=t(),pe=4;function me(e,t,n){if(!e||t<0)return null;let r=e.querySelector(`.mdw-lp-block[data-i="${t}"]`);if(r)return r;let i=[...Array.from(e.querySelectorAll(`h2`)).filter(e=>(e.textContent||``).trim()===`上一轮完成总结`),...Array.from(e.querySelectorAll(`.md-callout-t`)).filter(e=>/完成总结/.test(e.textContent||``))].sort((e,t)=>e.compareDocumentPosition(t)&4?-1:1);return i[n]?i[n]:null}function he({nodes:e=[],scrollRoot:t=null,onJump:n=null}){let[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(0),[s,c]=(0,q.useState)(de),[l,u]=(0,q.useState)(!1),d=(0,q.useRef)(null),f=(0,q.useRef)(null),p=(0,q.useRef)(!1);(0,q.useEffect)(()=>{let e=d.current,t=e&&e.parentElement;if(!e||!t)return;let n=()=>{c(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=ue({x:n.x,y:n.y,parentW:r.width,parentH:r.height,railW:i.width,railH:i.height});return a&&(a.x!==n.x||a.y!==n.y)?a:n})};return n(),window.addEventListener(`resize`,n,{passive:!0}),()=>window.removeEventListener(`resize`,n)},[]);let m=(0,q.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=d.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();r?t.style.bottom=r:t.style.bottom=``;let a=n.getBoundingClientRect();f.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-a.left,startTop:i.top-a.top,parentW:a.width,parentH:a.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),h=(0,q.useCallback)(e=>{let t=f.current;if(!t||e.pointerId!==t.pointerId)return;let n=e.clientX-t.startX,r=e.clientY-t.startY;if(!t.moved){if(Math.hypot(n,r)<pe)return;t.moved=!0,p.current=!0,u(!0),document.body.style.userSelect=`none`}let i=ue({x:t.startLeft+n,y:t.startTop+r,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});i&&(t.last=i,c(i))},[]),g=(0,q.useCallback)(e=>{let t=f.current;t&&e.pointerId===t.pointerId&&(f.current=null,t.moved&&(u(!1),document.body.style.userSelect=``,fe(t.last)))},[]),_=(0,q.useCallback)(()=>{c(null),fe(null)},[]),v=(0,q.useMemo)(()=>(e||[]).map(e=>({...e,title:ce(e)})),[e]);(0,q.useEffect)(()=>{let e=t;if(!e||!v.length)return;let n=()=>{let t=e.getBoundingClientRect(),n=0;for(let r of v){let i=me(e,r.blockIndex,r.round-1);i&&i.getBoundingClientRect().top-t.top<=40&&(n=r.round)}o(n)};return n(),e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[t,v]);let y=(0,q.useCallback)(e=>{let r=t,i=r?me(r,e.blockIndex,e.round-1):null;i&&(i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e.round)),n?.(e)},[t,n]);return v.length?(0,X.jsxs)(`aside`,{ref:d,className:`doc-rail ack-rail`+(r?` open`:``)+(l?` dragging`:``),style:s?{left:s.x,top:s.y,right:`auto`,bottom:`auto`}:void 0,"aria-label":`验收轮次`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:r?`收起轮次(双击回默认位)`:`展开轮次 · 按住拖动 · 双击回默认位`,"aria-expanded":r,onClick:()=>{if(p.current){p.current=!1;return}i(e=>!e)},onPointerDown:m,onPointerMove:h,onPointerUp:g,onPointerCancel:g,onDoubleClick:_,children:[(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]}),(0,X.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`验收轮次`,children:v.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(a===e.round?` on`:``),style:{"--tw":`18px`},title:e.title,"aria-current":a===e.round?`true`:void 0,onClick:()=>y(e)},e.round))}),r&&(0,X.jsx)(`div`,{className:`doc-rail-panel`,children:(0,X.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,X.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`验收轮次`}),v.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(a===e.round?` on`:``),title:e.ackText,onClick:()=>y(e),children:[`第 `,e.round,` 轮`]},e.round))]})})]}):null}var ge=[{op:`bold`,label:`B`,title:`粗体`,cls:`b`},{op:`italic`,label:`I`,title:`斜体`,cls:`i`},{op:`code`,label:`</>`,title:`代码`,cls:`code`},{op:`link`,label:`链`,title:`链接`,cls:`link`}];function _e({at:e,onFormat:t,onCopy:n,onCompose:r,onDelete:i}){if(!e)return null;let a=e.kind||`task`,o=a===`format`||a===`both`;return(0,X.jsx)(`div`,{id:`mdw-sel-menu`,className:`mdw-sel-menu open kind-${a}`,style:{left:e.x,top:e.y},role:`menu`,onMouseDown:e=>{e.target.closest?.(`textarea, input, button`)||e.preventDefault()},children:o?(0,X.jsxs)(`div`,{className:`mdw-sel-fmt`,role:`group`,"aria-label":`选区格式`,children:[ge.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn ${e.cls}`,title:e.title,onClick:()=>t?.(e.op),children:e.label},e.op)),(0,X.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn`,title:`复制`,onClick:n,children:`复制`}),(0,X.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn comment`,title:`评论 → 打开 md 编辑面板`,onClick:()=>r?.(),children:`评论`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`cap`,children:`选区`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>r?.(),children:`评论`}),(0,X.jsx)(`div`,{className:`sep`}),(0,X.jsx)(`button`,{type:`button`,onClick:n,children:`复制选区`}),i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`sep`}),(0,X.jsx)(`button`,{type:`button`,className:`danger`,title:`删除选区触到的整段块`,onClick:i,children:`删除选区`})]}):null]})})}var ve=[{title:`格式`,items:[[`Ctrl/⌘ B`,`粗体`],[`Ctrl/⌘ I`,`斜体`],[`Ctrl/⌘ E`,`行内代码`],[`Ctrl/⌘ K`,`链接`],[`1 – 6`,`正文 / 标题 / 小标题 / 列表 / 待办 / 引用`]]},{title:`编辑`,items:[[`/`,`行首唤起命令菜单`],[`Tab / ⇧Tab`,`缩进 / 反缩进`],[`Enter`,`新建块(列表自动续行)`],[`⇧Enter`,`块内软换行`],[`Ctrl/⌘ Z`,`撤销`],[`Ctrl/⌘ ⇧Z`,`重做`]]},{title:`导航与文件`,items:[[`Ctrl/⌘ F`,`查找(Enter 下一个,F3 继续)`],[`Ctrl/⌘ S`,`保存并同步`],[`Ctrl/⌘ ⇧ O`,`评论任务:右侧并排打开原文`],[`Ctrl/⌘ /`,`打开 / 关闭本速查`],[`Enter(标题内)`,`跳到正文`]]}];function ye({onClose:e}){return(0,X.jsx)(i,{title:`快捷键`,onClose:e,size:`lg`,className:`mdw-sheet`,children:(0,X.jsx)(`div`,{className:`mdw-sheet-cols`,children:ve.map(e=>(0,X.jsxs)(`section`,{className:e.title===`导航与文件`?`wide`:void 0,children:[(0,X.jsx)(`h4`,{children:e.title}),(0,X.jsx)(`dl`,{children:e.items.map(([e,t])=>(0,X.jsxs)(`div`,{className:`mdw-sheet-row`,children:[(0,X.jsx)(`dt`,{children:(0,X.jsx)(`kbd`,{children:e})}),(0,X.jsx)(`dd`,{children:t})]},e))})]},e.title))})})}var be={origin:`起点`,reopen:`反馈`,comment:`评论`,current:`当前`};function xe({nodes:e=[],onOpenNode:t}){return e.length?(0,X.jsx)(`ol`,{className:`mdw-chain-list`,"aria-label":`任务链节点`,children:e.map((n,r)=>{let i=n.current?`current`:`t-${n.dirKey||``}-${n.id??n.taskId??r}`,a=be[n.kind]||n.kind||`?`,o=n.excerpt||n.feedback||a,s=[n.taskId==null?null:`#${n.taskId}`,n.at||null,n.attachmentCount?`📎${n.attachmentCount}`:null].filter(Boolean).join(` · `);return(0,X.jsxs)(`li`,{className:`mdw-chain-li${n.current?` is-current`:``}`,children:[(0,X.jsxs)(`div`,{className:`mdw-chain-rail`,"aria-hidden":!0,children:[(0,X.jsx)(`span`,{className:`mdw-chain-dot`}),r<e.length-1?(0,X.jsx)(`span`,{className:`mdw-chain-line`}):null]}),(0,X.jsxs)(`button`,{type:`button`,className:`mdw-chain-card${n.kind===`comment`?` is-comment`:``}`,title:n.current?`当前任务(本页)`:`查看:${o}`,disabled:!!n.current,onClick:()=>{n.current||t?.(n)},children:[(0,X.jsx)(`span`,{className:`mdw-chain-kind`,children:a}),(0,X.jsx)(`span`,{className:`mdw-chain-ex`,children:o||`—`}),s?(0,X.jsx)(`span`,{className:`mdw-chain-meta`,children:s}):null]})]},i)})}):(0,X.jsx)(`div`,{className:`mdw-chain-empty muted`,children:`这条任务还没有链(反馈 / 评论派生后会出现)`})}function Se({open:e,nodes:t,onOpenNode:n,onClose:r}){return e?(0,X.jsxs)(i,{title:`任务链`,onClose:r,size:`md`,className:`mdw-chain-modal`,children:[(0,X.jsx)(`p`,{className:`mdw-chain-hint`,children:`从早到晚排列。点非当前节点可在旁路打开内容。`}),(0,X.jsx)(xe,{nodes:t,onOpenNode:e=>{n?.(e),r?.()}})]}):null}function Ce(){let[e,t]=(0,q.useState)(()=>localStorage.getItem(`nxkv.taskDockOpen`)!==`0`),[n,r]=(0,q.useState)(()=>localStorage.getItem(`nxkv.taskDockTab`)||`attach`),[i,a]=(0,q.useState)(()=>{let e=Number(localStorage.getItem(`nxkv.taskDockH`));return Number.isFinite(e)&&e>=96?e:176}),o=(0,q.useRef)(i);o.current=i;let s=(0,q.useRef)(null),[c,l]=(0,q.useState)(!1),u=(0,q.useRef)(176);return(0,q.useEffect)(()=>{localStorage.setItem(`nxkv.taskDockOpen`,e?`1`:`0`)},[e]),(0,q.useEffect)(()=>{localStorage.setItem(`nxkv.taskDockTab`,n)},[n]),{dockOpen:e,setDockOpen:t,dockTab:n,setDockTab:r,dockH:i,dockHRef:o,dockRef:s,dockMax:c,setDockMax:l,dockPrevHRef:u,showDockTab:(0,q.useCallback)(e=>{r(e),t(!0)},[]),onDockDragStart:(0,q.useCallback)(t=>{if(!e)return;t.preventDefault(),l(!1);let n=t.clientY,r=o.current,i=s.current?.parentElement?.clientHeight||window.innerHeight,c=e=>Math.max(96,Math.min(Math.round(i*.62),Math.round(e))),u=e=>{let t=c(r-(e.clientY-n));o.current=t,a(t)},d=()=>{window.removeEventListener(`mousemove`,u),window.removeEventListener(`mouseup`,d),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`nxkv.taskDockH`,String(o.current))};document.body.style.userSelect=`none`,document.body.style.cursor=`row-resize`,window.addEventListener(`mousemove`,u),window.addEventListener(`mouseup`,d)},[e]),toggleDockMax:(0,q.useCallback)(()=>{if(c){a(u.current),l(!1);return}u.current=o.current;let e=s.current?.parentElement?.clientHeight||window.innerHeight,t=Math.max(96,Math.round(e*.62));o.current=t,a(t),l(!0)},[c])}}function we({id:e,isDraft:t,topicKey:n,task:i,taskRow:a}){let[o,s]=(0,q.useState)(null);(0,q.useEffect)(()=>{s(null)},[e]);let c=a?.timegoal||null,l=o||{duration:c?.duration||``,prompt:c?.prompt||``},u=t||!!a&&a.status===`pending`,d=!t&&!!c&&i!=null,[f,p]=(0,q.useState)({busy:!1,error:``,data:null}),m=(0,q.useCallback)(()=>{if(t||!n||i==null)return;p(e=>({...e,busy:!0,error:``}));let e=new URLSearchParams({id:String(i),key:String(n)});r(`/api/localtasks/timegoal-log?${e.toString()}`).then(e=>p(t=>({...t,data:e,busy:!1}))).catch(e=>p(t=>({...t,busy:!1,error:String(e.message||e)})))},[t,n,i]);return(0,q.useEffect)(()=>{d&&m()},[d,m]),{goalDraft:o,setGoalDraft:s,goal:l,goalEditable:u,declaredGoal:c,goalLog:f,loadGoalLog:m,canShowGoalLog:d}}function Te({isDraft:e,task:t,taskRow:n,topicKey:i,topic:a,isGlobal:o,groupAnchored:s,groupId:c,app:u,model:d,historyId:f,toast:p}){let[m,h]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(e||t==null||/^draft/i.test(String(t))){h(null);return}let n=!1,i=o?`key=${encodeURIComponent(k)}&id=${Number(t)}`:`cwd=${encodeURIComponent(a?.cwd||``)}&id=${Number(t)}`;return r(`/api/localtasks/chain?${i}`).then(e=>{n||h(e)}).catch(()=>{n||h(null)}),()=>{n=!0}},[e,t,o,a?.cwd,n?.history?.length,n?.forkOf,n?.reopenCount]);let g=(0,q.useMemo)(()=>{if(e||!n)return[];let r=(String(n.text||``).split(`
7
7
  `).map(e=>e.trim()).find(Boolean)||``).replace(/^#+\s*/,``).slice(0,100),a=Array.isArray(n.history)?n.history:[];if(a.length){let e=a.map(e=>({historyId:e.id,kind:e.kind,at:e.at,excerpt:e.excerpt||e.feedback||``,feedback:e.feedback,quote:e.quote,attachmentCount:(e.attachments||[]).length,current:!1}));return e.push({historyId:null,kind:`current`,at:n.lastReopenedAt||n.createdAt||``,excerpt:r,attachmentCount:0,current:!0}),e}let o=Array.isArray(m?.ancestors)?[...m.ancestors].reverse():[],s=Array.isArray(m?.children)?m.children:[];if(!o.length&&!s.length&&!n.forkOf)return[];let c=[];for(let e of o)e.missing||c.push({historyId:null,kind:e.forkKind||`origin`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});c.push({historyId:null,kind:`current`,at:n.createdAt||``,excerpt:r,attachmentCount:0,current:!0,taskId:Number(t),dirKey:i||`__GLOBAL__`});for(let e of s)c.push({historyId:null,kind:e.forkKind||`comment`,at:e.createdAt||``,excerpt:e.excerpt||`#${e.id}`,attachmentCount:0,current:!1,taskId:e.id,dirKey:e.key});return c},[e,n,m,t,i]),_=(0,q.useMemo)(()=>{if(f==null||!n)return null;let e=Number(f);return(n.history||[]).find(t=>Number(t.id)===e)||null},[f,n]),v=Array.isArray(m?.children)?m.children:[],y=v.length===0,b=v.length?v[v.length-1]:null;return{chainApi:m,chainNodes:g,historyNode:_,chainChildren:v,isChainTip:y,latestChild:b,openLatestRound:(0,q.useCallback)(()=>{b&&u.openPage&&(s?u.openPage({groupId:c,task:String(b.id),name:`#${b.id}`}):u.openPage({dirKey:String(b.key||i||`__GLOBAL__`),task:String(b.id),name:`#${b.id}`}))},[b,u.openPage,s,c,i]),openHistoryBeside:(0,q.useCallback)(n=>{let r=d||u.model;if(r&&!e){if(n?.current){p(`当前节点就是本页`);return}if(n?.historyId!=null){l(r,{component:`page`,name:`链 #${t} · ${n.kind||n.historyId}`,config:{dirKey:i||`__GLOBAL__`,task:String(t),historyId:Number(n.historyId)}});return}if(n?.taskId!=null&&n?.dirKey){l(r,{component:`page`,name:n.excerpt?String(n.excerpt).slice(0,24):`#${n.taskId}`,config:{dirKey:String(n.dirKey),task:String(n.taskId)}});return}p(`这个节点没有可打开的内容`)}},[d,u.model,e,i,t,p])}}function Ee({id:e}){let[t,n]=(0,q.useState)(null),r=(0,q.useRef)(``);return(0,q.useEffect)(()=>{n(null),r.current=``},[e]),(0,q.useEffect)(()=>{let e=()=>n(null);return document.addEventListener(`scroll`,e,!0),()=>document.removeEventListener(`scroll`,e,!0)},[]),{selMenu:t,setSelMenu:n,lastSel:r,placeSelMenu:(0,q.useCallback)((e,t,i,a,o={})=>{r.current=t,n({kind:e,text:t,...o,x:Math.min(window.innerWidth-300,Math.max(8,i)),y:Math.min(window.innerHeight-240,Math.max(8,a))})},[]),onEditorTextSel:(0,q.useCallback)(e=>{if(!e?.text||e.text.length<1){n(null);return}r.current=e.text,n({kind:`format`,text:e.text,x:Math.min(window.innerWidth-300,Math.max(8,e.x)),y:Math.min(window.innerHeight-240,Math.max(8,e.y))})},[]),closeSelMenu:(0,q.useCallback)(()=>{n(null),r.current=``},[])}}function De({id:e,taskRow:t,dockTab:n,dockOpen:r}){let[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),c=(0,q.useRef)(null),l=String(t?.roundSummary||``).length>140;return(0,q.useEffect)(()=>{a(!1),s(!1)},[e,t?.roundSummary]),(0,q.useLayoutEffect)(()=>{let e=c.current;if(!e){s(!1);return}let t=()=>{i||s(e.scrollHeight>e.clientHeight+1)};t();let n=requestAnimationFrame(t),r=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return r?.observe(e),()=>{cancelAnimationFrame(n),r?.disconnect()}},[i,t?.roundSummary,t?.completedAt,n,r]),{ackOpen:i,setAckOpen:a,ackOverflow:o,reviewSumRef:c,ackLong:l}}function Oe({doc:e,id:t,isDraft:n,task:i,taskRow:o,topicKey:s,topic:l,isGlobal:d,boardCtx:h,docFm:g,groupAnchored:v,groupId:y,rows:b,app:S,model:w,tabId:T,tpl:O,refreshLocal:A,markDirty:N,histRef:P,editorApiRef:z,attachAreaRef:ee,setDirty:H,goal:te,goalEditable:ne,declaredGoal:U,guard:W,dialog:G,showDockTab:re}){let K=a(),J=(0,q.useCallback)((e,t)=>{let n=(e||``).trim()||`未命名任务`,r=m(t),i=Object.keys(r).length>0,a=f(t);return a=_(a),a=/^#\s+/m.test(a)?a.replace(/^#\s+.+$/m,`# ${n}`):`# ${n}\n\n${a}`,i?p(a,r):a},[]),Y=(0,q.useCallback)(()=>{let e=(te.duration||``).trim(),t=(te.prompt||``).trim();if(t&&!e)return{error:`时间目标要填时长(如 2h / 90m);只写附加要求无效`};if(!ne)return{};if(!n){let n=U?.duration||``,r=U?.prompt||``;return e===n&&t===r?{}:e?{duration:e,goalPrompt:t}:{clearGoal:!0}}return e?{duration:e,goalPrompt:t}:{}},[te,ne,n,U]),ie=(0,q.useCallback)(()=>W(async()=>{if(!e)return;let a=(e.title||``).trim()||`未命名任务`,o=m(e.body),c=J(a,e.body),f=o.project?b.find(e=>!e.isGlobal&&e.repo&&e.repo.key===o.project):null,p=!!(h&&o.project&&h.members.some(e=>e.key===o.project)),g=Y();if(g.error){K(g.error);return}if(!n){let n=await r(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:d?f?f.cwd:void 0:l?.cwd,key:d&&!f?k:void 0,id:Number(i),text:c,...g}});if(n?.moved){let r=n.key||s,o=String(n.task?.id??i),l=L(F(r),o);B(o,e.attachments),M(t,l,{title:a,body:n.task?.text||c}),w&&T&&w.doAction(u.updateNodeAttributes(T,{config:v?{groupId:y,task:o}:{dirKey:r,task:o}})),S.onNavigate&&S.onNavigate(v?`#/group/${encodeURIComponent(y||``)}?task=${encodeURIComponent(o)}`:`#/dir/${encodeURIComponent(r||``)}?task=${encodeURIComponent(o)}`),H(!1),C(P.current,l),K(`已改归属项目:任务迁到「${n.name}」#${o}`),A();return}B(i,e.attachments),I(t,{title:a,body:c}),H(!1),C(P.current,t),K(g.clearGoal?`已同步 MD · 时间目标已清除`:g.duration?`已同步 MD · 时间目标已更新`:`已同步 MD`),A();return}let _=await r(`/api/localtasks`,{method:`POST`,body:{...p?{text:c,board:h.board.id,project:o.project}:o.project?{text:c,project:o.project}:d?{global:!0,text:c}:{cwd:l?.cwd,text:c},...g}}),x=_?.task?.id??_?.id;if(x!=null){let n=_?.key||s,r=F(n);B(x,e.attachments);let i=L(r,String(x));M(t,i,{title:a,body:c}),w&&T&&w.doAction(u.updateNodeAttributes(T,{config:v?{groupId:y,task:String(x)}:{dirKey:n,task:String(x)}})),S.onNavigate&&S.onNavigate(v?`#/group/${encodeURIComponent(y||``)}?task=${encodeURIComponent(String(x))}`:`#/dir/${encodeURIComponent(n||``)}?task=${encodeURIComponent(String(x))}`),H(!1),C(P.current,i)}K(`已提交:${D(a)}`),A()}),[e,t,n,i,s,l,d,h,v,y,b,S,w,T,A,P,H,J,Y,W,K]),ae=(0,q.useCallback)(async e=>{let t=await e.text(),n=e.name.replace(/\.md$/i,``);await W(async()=>{let i=t.startsWith(`#`)?t:`# ${n}\n\n${t}`,a=await r(`/api/localtasks`,{method:`POST`,body:d?{global:!0,text:i}:v&&g.project?{project:g.project,text:i}:{cwd:l?.cwd,text:i}});K(`已导入:${e.name}`),A();let o=a?.task?.id??a?.id;o!=null&&S.openPage&&(v?S.openPage({groupId:y,task:String(o),name:`#${o}`}):S.openPage({dirKey:s,task:String(o),name:`#${o}`}))})},[d,v,g.project,l?.cwd,s,y,S,A,W,K]),oe=(0,q.useCallback)(async()=>{if(!e||n)return;let t=e.title||`#${i}`;await G({title:`删除任务「${t}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&W(async()=>{await r(`/api/localtasks/item`,{method:`DELETE`,body:d?{key:k,id:Number(i)}:{cwd:l.cwd,id:Number(i)}}),K(`已删除「${t}」`),w&&T&&w.doAction(u.deleteTab(T)),A()})},[e,n,i,d,l,w,T,A,W,K,G]),se=!n&&!!o&&o.status===`pending`;return{composeText:J,goalPatchOf:Y,submit:ie,importMd:ae,delTask:oe,canClosePending:se,closeTask:(0,q.useCallback)(t=>{se&&W(async()=>{let n=e?.title||`#${i}`,a=d?{key:k}:{cwd:l?.cwd};if(t===`done`){let e=await G({title:`标为完成「${n}」`,message:`任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。`,input:!0,placeholder:`完成总结(可选;留空使用默认说明)`,okText:`标为完成`});if(e==null)return;await r(`/api/localtasks/items/close`,{method:`POST`,body:{...a,ids:[Number(i)],status:`done`,summary:String(e).trim()}}),K(`已标为完成 #${i}`)}else{if(!await G({title:`取消任务「${n}」`,message:`只处理待领取任务。取消为终态,原文留档。`,danger:!0,okText:`取消任务`}))return;await r(`/api/localtasks/items/close`,{method:`POST`,body:{...a,ids:[Number(i)],status:`cancelled`}}),K(`已取消 #${i}`)}A()})},[se,e,i,d,l,A,W,K,G]),addFiles:(0,q.useCallback)(async(a,o={})=>{if(!e)return;let{items:s,imageInserts:c,fileInserts:u}=await V(a),f=j(t)||e,p=f.body||``,m=c.join(``),h=p,g=null;if(m){let e=x(p,m,o);h=e.body,g=e.insertAt+m.length}u.length&&(h=x(h,u.join(``),{}).body);let _={};if(h!==p&&(_.body=h),s.length&&(_.attachments=[...f.attachments||[],...s]),Object.keys(_).length){if(I(t,_),o.mode===`edit`&&g!=null&&requestAnimationFrame(()=>{z.current?.focus?.();let e=document.querySelector(`.mdw-editor`);if(e)try{e.setSelectionRange(g,g)}catch{}}),!n){_.attachments&&B(i,_.attachments);let e=J(f.title,_.body||h);I(t,{body:e,title:E(e)});try{await r(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:d?void 0:l?.cwd,key:d?k:void 0,id:Number(i),text:e}}),H(!1),A(),K(s.length?`已添加附件并同步(${s.length})`:`已同步附件`)}catch(e){N(),K(`附件已插入,同步失败:${e.message||e}`)}return}N()}},[e,t,n,i,l,d,H,A,N,J,z,K]),newTask:(0,q.useCallback)(()=>{let e=R(),t=L(F(v?y:s),e),n={};h&&h.board&&h.board.id&&(n.board=h.board.id),g.project&&(n.project=g.project),I(t,{title:``,body:p(O?O.defaultBody():``,n)}),S.openPage&&S.openPage(v?{groupId:y,task:e,name:`新任务`}:{dirKey:s,task:e,name:`新任务`})},[h,g.project,v,y,s,S,O]),cloneCur:(0,q.useCallback)(()=>{if(n||i==null||/^draft/i.test(String(i))){K(`草稿没有可克隆的队列任务`);return}W(async()=>{let t=await r(`/api/localtasks/clone`,{method:`POST`,body:d?{id:Number(i)}:{id:Number(i),cwd:l?.cwd}});K(`已克隆为新任务 #${t.task?.id??t.id}`),A();let n=t?.task?.id??t?.id;n!=null&&S.openPage&&(v?S.openPage({groupId:y,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}):S.openPage({dirKey:s,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}))})},[n,i,d,l,v,y,s,S,e,A,W,K]),forkCur:(0,q.useCallback)(()=>{if(n||i==null||/^draft/i.test(String(i))){K(`草稿没有可 Fork 的队列任务`);return}W(async()=>{let t=await r(`/api/localtasks/fork`,{method:`POST`,body:d?{id:Number(i)}:{id:Number(i),cwd:l?.cwd}});K(`已 Fork 为新任务 #${t.task?.id??t.id}(保留任务链)`),A();let n=t?.task?.id??t?.id;n!=null&&S.openPage&&(v?S.openPage({groupId:y,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}):S.openPage({dirKey:s,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}))})},[n,i,d,l,v,y,s,S,e,A,W,K]),openProgress:(0,q.useCallback)(()=>{let e=w||S.model;if(!e)return;let t=g&&g.board?String(g.board):``;c(e,{component:`progress`,name:`进程`,config:t?{groupKey:t,task:i==null?void 0:String(i)}:{dirKey:s||`__GLOBAL__`,task:i==null?void 0:String(i)},location:`right`})},[w,S.model,g,i,s]),openAttachPanel:(0,q.useCallback)(()=>{re(`attach`),setTimeout(()=>ee.current?.open(),0)},[re,ee])}}function ke({doc:e,isDraft:t,task:n,taskRow:i,topicKey:o,topic:s,isGlobal:c,dirKey:l,groupAnchored:d,groupId:f,app:p,model:m,tabId:h,refreshLocal:g,closeSelMenu:_,lastSel:v,selMenu:y,dirty:b,setDirty:x,guard:S}){let C=a(),w=(0,q.useCallback)(async()=>{if(t||n==null||/^draft/i.test(String(n)))return null;let e=c?`key=${encodeURIComponent(k)}&id=${Number(n)}`:`cwd=${encodeURIComponent(s?.cwd||``)}&id=${Number(n)}`;return r(`/api/localtasks/item?${e}`).catch(()=>null)},[t,n,c,s?.cwd]),T=(0,q.useCallback)(()=>{let t=m||p.model;t&&ee(t,{mode:`feedback`,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),prevQuote:String(i?.roundSummary||``).trim()||String(e?.body||``).trim().slice(0,400),src:{dirKey:o||l||`__GLOBAL__`,task:String(n),name:`原文 #${n}`},onSubmit:e=>D(e)})},[m,p.model,n,e,i,o,l]),D=(0,q.useCallback)(({text:a,attachments:l=[],inserts:u=``}={})=>{let m=String(a||``).trim();if(_(),!m&&!(l&&l.length)){C(`写一下反馈`);return}let h=e?.title||`#${n}`;S(async()=>{let a=await w(),_=String(a?.text??``).trim()||String(e?.body??``).trim();if(!_&&!t){C(`拿不到任务当前正文,已取消反馈(防止丢内容)`);return}let v=m||`(见附件)`;u&&(v=`${v}${u}`);let y=G({base:_,feedback:v,ackSummary:a?.roundSummary||i?.roundSummary||``,feedbackHeading:U,bold:!0}),b=!t&&n!=null&&!/^draft/i.test(String(n))?{forkOf:String(n),forkKind:`reopen`}:{},x=await r(`/api/localtasks`,{method:`POST`,body:c?{global:!0,text:y,...b}:{cwd:s?.cwd,text:y,...b}}),S=String(x?.task?.id??x?.id??``);if(!S){C(`反馈已提交,但未拿到新任务编号`),g();return}let T=x?.key||o;I(L(F(T),S),{title:E(y),body:y}),l?.length&&B(S,l),C(`已反馈「${h}」→ 新任务 #${S}`),g(),p.openPage&&(d?p.openPage({groupId:f,task:S,name:`${h.slice(0,24)}(反馈)`}):p.openPage({dirKey:T,task:S,name:`${h.slice(0,24)}(反馈)`}))})},[e,n,i,t,c,s,o,d,f,p,g,_,S,C,w]),O=(0,q.useCallback)(({text:i,attachments:a=[],inserts:l=``,quote:d}={})=>{let f=String(i||``).trim(),p=String(d||v.current||``).trim();if(_(),!f&&!(a&&a.length)){C(`写一下要提的问题`);return}if(!p&&!f){C(`先划选一段再评论`);return}if(t||n==null||/^draft/i.test(String(n))){C(`草稿先提交成任务再评论`);return}let y=e?.title||`#${n}`;S(async()=>{let t=!b&&!l&&!(a&&a.length),i;if(!t){let t=await w(),n=String(t?.text??``).trim()||String(e?.body??``).trim();if(!n){C(`拿不到任务当前正文,已取消评论(防止丢内容)`);return}let r=[ne(p),f||`(见附件)`,l].filter(Boolean).join(`
8
8
 
9
- `);i=G({base:n,feedback:r,ackSummary:``,feedbackHeading:W,bold:!1})}let d=await r(`/api/localtasks/reopen`,{method:`POST`,body:{...c?{key:k}:{cwd:s?.cwd},id:Number(n),...i?{text:i}:{},kind:`comment`,quote:p,feedback:f,attachments:(a||[]).map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,url:e.url||``}))}}),_=d?.key||o,v=String(d?.task?.id??n),S=String(d?.task?.text??i??``);S&&I(L(F(_),v),{title:E(S),body:S}),a?.length&&B(v,[...e?.attachments||[],...a]),m&&h&&_!==o&&m.doAction(u.updateNodeAttributes(h,{config:{dirKey:_,task:v}})),x(!1),C(`已回写评论「${y}」#${v}`),g()})},[e,n,t,c,s,o,m,h,g,_,v,b,x,S,C,w]);return{fetchServerTask:w,openFeedback:T,spawnFeedbackTask:D,submitCommentInPlace:O,openCommentFromToolbar:(0,q.useCallback)(()=>{let t=String(window.getSelection()||``).trim()||(y?.text?String(y.text):``);if(!t){C(`先划选一段再评论`);return}v.current=t;let r=m||p.model;r&&(ee(r,{mode:`comment`,quote:t,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),src:{dirKey:o||l||`__GLOBAL__`,task:String(n),name:`原文 #${n}`},onSubmit:e=>O({...e,quote:t})}),_())},[e,n,o,l,m,p.model,v,y,O,_,C])}}function Ae({doc:e,beside:t,topicKey:n,topic:r,task:i,app:a}){let o=(0,q.useMemo)(()=>e?m(e.body):{},[e&&e.body]);return{docFm:o,parentRef:(0,q.useMemo)(()=>{if(t)return null;let a=String(o.parent||``).trim(),s=String(o.parentDir||n||``).trim();if(a&&!/^draft/i.test(a))return{dirKey:s||n,task:a,name:`#${a}`};let c=String(e?.body||``).match(/>\s*锚定自「([^」]+)」/);if(!c)return null;let l=c[1].trim(),u=(r?.tasks||[]).find(e=>String(e.id)===String(i)?!1:E(e.text||``)===l||String(e.text||``).includes(`# ${l}`));return u?{dirKey:n,task:String(u.id),name:`#${u.id}`}:null},[t,o.parent,o.parentDir,e?.body,n,r,i]),boardCtx:(0,q.useMemo)(()=>{let e=o.board;if(!e)return null;let t=(a.repoData&&a.repoData.boards||[]).find(t=>t.id===e||t.key===e||t.name===e);if(!t)return null;let n=a.repoData&&a.repoData.repos||[],r=new Map(n.map(e=>[e.key,e]));return{board:t,members:(t.repos||[]).map(e=>r.get(e.key)).filter(Boolean).map(e=>({key:e.key,name:e.name}))}},[o.board,a.repoData])}}function je({state:e,onClose:t}){let n=a(),r=e?.data,o=async()=>{try{await navigator.clipboard.writeText(String(r?.rendered||``)),n(`已复制原文`)}catch{n(`复制失败(剪贴板不可用)`)}},s=r?.switches||{},c=r?[`ack ${s.ack?.on?`开(${s.ack.count} 条)`:`关`}`,`交付上下文 ${s.deliveryTemplate?.custom?`自定义`:`内置默认`}`,`持续 get ${r.getLoop?.enabled?`开(${r.getLoop.waitMinutes} 分钟)`:`关`}`].join(` · `):``,l=r?`预览:agent 执行 get 会收到的提示词${r.task?.id?` · #${r.task.id}`:` · 草稿`}`:`预览:agent 执行 get 会收到的提示词`;return(0,X.jsxs)(i,{title:l,size:`wide`,onClose:t,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mdw-prev-hint`,children:`与 CLI 取任务共用同一份排版;不含「已取得下一条任务…」头部行。`}),(0,X.jsx)(`span`,{className:`grow`}),(0,X.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:o,disabled:!r,children:`复制原文`}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:t,children:`关闭`})]}),children:[e.busy&&(0,X.jsx)(`div`,{className:`mdw-prev-note`,children:`渲染中…`}),e.error&&(0,X.jsxs)(`div`,{className:`mdw-prev-note`,children:[`预览失败:`,e.error,/接口不存在/.test(String(e.error))&&(0,X.jsx)(`div`,{className:`mdw-prev-hint`,children:`本机面板服务较旧:重启面板(结束当前 serve 进程后重新启动)即可生效,刷新页面不够。`})]}),r&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`mdw-prev-body`,children:r.rendered||``}),r.segments?.length?(0,X.jsxs)(`details`,{className:`mdw-prev-seg`,children:[(0,X.jsxs)(`summary`,{children:[`段落来源(`,r.segments.length,` 段)`]}),(0,X.jsx)(`ol`,{children:r.segments.map((e,t)=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`mdw-prev-seg-lab`,children:e.label}),(0,X.jsxs)(`span`,{className:`mdw-prev-seg-n`,children:[String(e.text||``).length,` 字`]})]},t))}),(0,X.jsx)(`div`,{className:`mdw-prev-note`,children:`改这些段去「设置 → 提示词 / 模板」;「持续 get」在项目级设置里。`})]}):(0,X.jsx)(`div`,{className:`mdw-prev-note`,children:`当前没有任何模板段:交付时就只有任务正文。`}),(0,X.jsx)(`div`,{className:`mdw-prev-switch`,children:c})]})]})}function Me(e){let t=Math.max(0,Number(e)||0);return t>=3600?`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`:t>=60?`${Math.floor(t/60)}m ${t%60}s`:`${t}s`}function Ne({dockOpen:e,dockTab:t,dockH:n,dockRef:r,dockMax:i,showDockTab:a,onDockDragStart:s,toggleDockMax:l,setDockOpen:u,canShowGoalLog:d,goalLog:f,openGoalLog:p,isDraft:m,task:h,topic:g,topicKey:_,isGlobal:v,doc:y,id:b,model:x,app:S,refreshLocal:C,markDirty:T,saveDoc:E,persistAtt:D,attachAreaRef:O,reviewBarRef:A,reviewSumRef:j,taskRow:M,ackOpen:N,setAckOpen:P,ackOverflow:F,ackLong:I,ackHtml:L,isChainTip:R,latestChild:z,openFeedback:B,openLatestRound:V}){return e?(0,X.jsxs)(`div`,{className:`mdw-dock`,ref:r,style:{height:`${n}px`},children:[(0,X.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:s,onDoubleClick:l}),(0,X.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,X.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`attach`,className:`mdw-dock-tab${t===`attach`?` is-on`:``}`,onClick:()=>a(`attach`),children:`附件`}),d?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`check`,className:`mdw-dock-tab${t===`check`?` is-on`:``}`,onClick:p,children:[`check`,(0,X.jsx)(`span`,{className:`mdw-dock-tab-num`,children:f.data?.count??0})]}):null,(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`feedback`,className:`mdw-dock-tab${t===`feedback`?` is-on`:``}`,onClick:()=>a(`feedback`),children:`反馈`})]}),(0,X.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,X.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:l,title:i?`还原面板高度`:`最大化面板高度`,"aria-label":i?`还原面板高度`:`最大化面板高度`,children:(0,X.jsx)(o,{name:i?`collapse`:`expand`})}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>u(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,X.jsx)(o,{name:`x`})})]})]}),(0,X.jsxs)(`div`,{className:`mdw-dock-body`,children:[t===`attach`?m?(0,X.jsx)(H,{attachments:y.attachments,onRemove:e=>{let t=(y.attachments||[]).filter(t=>t.id!==e);T(),E(b,{attachments:t}),m||D(h,t)}}):g?(0,X.jsx)(K,{ref:O,host:`task`,hostId:Number(h),hostKey:v?k:void 0,hostCwd:v?void 0:g.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(g.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status})),onChanged:C,onOpenTask:e=>{S.openPage&&e&&e.seq!=null&&S.openPage({dirKey:e.key||_,task:String(e.seq),name:`#${e.seq}`})},onOpenDoc:e=>{let t=w(e);x&&t&&c(x,{component:`doc`,name:e.split(`/`).pop()||e,config:{docId:t},location:`center`})}}):(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`没有可挂载附件的上下文。`}):null,t===`check`?(0,X.jsxs)(`div`,{className:`mdw-dock-check`,children:[f.busy&&!f.data?(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,f.error?(0,X.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,f.error]}):null,f.data?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mdw-dock-meta mono`,children:[`时间目标 ${f.data.duration||`—`}`,f.data.startedAt?` · 开始 ${f.data.startedAt}`:``,f.data.deadline?` · 截止 ${f.data.deadline}`:` · 尚未开始计时`,f.data.archived?` · 已归档`:``,` · ${f.data.count||0} 轮`]}),(f.data.count||0)>0?(0,X.jsx)(`div`,{className:`mdw-goal-log`,children:f.data.entries.map((e,t)=>(0,X.jsxs)(`div`,{className:`mdw-goal-log-row`,children:[(0,X.jsxs)(`div`,{className:`mdw-goal-log-head mono`,children:[`R`,t+1,` · `,e.checkedAt,` · `,e.reached?`已到点`:`未到点`,` · 已用`,` `,Me(e.elapsedSec),` · 剩余 `,Me(e.remainingSec)]}),e.summary?(0,X.jsx)(`div`,{className:`mdw-goal-log-body`,children:e.summary}):null,e.progress?(0,X.jsx)(`div`,{className:`mdw-goal-log-prog`,children:e.progress}):null]},`${e.checkedAt}-${t}`))}):(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有 check 记录——任务领取后每轮 check 会出现在这里。`})]}):null]}):null,t===`feedback`?!m&&M?.completedAt?(0,X.jsxs)(`div`,{className:`mdw-review`,ref:A,children:[(0,X.jsxs)(`div`,{className:`mdw-review-main`,children:[(0,X.jsx)(`span`,{className:`mdw-review-badge`,children:`已完成 · 等待验收`}),(0,X.jsx)(`span`,{className:`mdw-review-at mono`,children:M.completedAt}),M.roundSummary?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{ref:j,className:`mdw-review-sum${N?` is-open`:``}`,title:N||!(F||I)?`agent 的完成总结(ack)`:`点击下方展开全文`,dangerouslySetInnerHTML:{__html:L}}),(F||I||N)&&(0,X.jsx)(`button`,{type:`button`,className:`mdw-review-more`,onClick:()=>P(e=>!e),children:N?`收起`:`展开全文`})]}):null]}),(0,X.jsx)(`div`,{className:`mdw-review-acts`,children:R?(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:B,title:`新开一条任务携带反馈(原任务不动)`,children:`反馈`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mdw-review-later`,title:`这条任务已有后续轮次——在旧轮次上反馈会把链分叉,请到最新一轮反馈`,children:`已进入后续轮次`}),z?(0,X.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:V,title:`到最新一轮 #${z.id} 反馈`,children:[`去最新一轮 #`,z.id]}):null]})})]}):(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`任务完成后,agent 的完成总结会显示在这里。`}):null]})]}):null}function Pe({dockOpen:e,dockTab:t,showDockTab:n,setDockOpen:r,canShowGoalLog:i,goalLog:a,openGoalLog:s,isDraft:c,taskRow:l}){return(0,X.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`attach`?` is-on`:``}`,onClick:()=>n(`attach`),title:`附件(点击展开信息面板)`,children:[(0,X.jsx)(o,{name:`list`}),(0,X.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`})]}),i?(0,X.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`check`?` is-on`:``}`,onClick:s,title:`时间目标每轮 check(点击展开信息面板)`,children:[(0,X.jsx)(o,{name:`clock`}),(0,X.jsx)(`span`,{className:`mdw-sbar-lab`,children:`check`}),(0,X.jsx)(`span`,{className:`mdw-sbar-num`,children:a.data?.count??0})]}):null,(0,X.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`feedback`?` is-on`:``}`,onClick:()=>n(`feedback`),title:`完成总结 / 反馈(点击展开信息面板)`,children:[(0,X.jsx)(o,{name:`edit`}),(0,X.jsx)(`span`,{className:`mdw-sbar-lab`,children:`反馈`})]}),(0,X.jsx)(`span`,{className:`mdw-sbar-grow`}),!c&&l?(0,X.jsx)(`span`,{className:`mdw-sbar-stat`,title:`任务状态`,children:(0,X.jsx)(z,{t:l})}):null,(0,X.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${e?` is-open`:``}`,onClick:()=>r(e=>!e),title:e?`收起信息面板`:`展开信息面板`,"aria-expanded":e,"aria-label":e?`收起信息面板`:`展开信息面板`,children:(0,X.jsx)(o,{name:`chevron`})})]})}function Fe({goal:e,setGoalDraft:t,goalEditable:n,declaredGoal:r,openGoalLog:i,markDirty:a,task:o}){let s=(e.duration||``).trim(),c=(e.prompt||``).trim();return{goalBadge:s||c?{label:`⏱ ${s||`目标`}`,title:c||(n?`任务级时间目标(在「更多」里设置;领取即计时)`:`已领取计时,声明不可改`)}:null,goalMenu:n||r?(0,X.jsxs)(`div`,{className:`mdw-goal-menu`,children:[(0,X.jsx)(`div`,{className:`mdw-goal-menu-lab`,children:`时间目标`}),n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{className:`mdw-goal-dur mono`,value:e.duration,placeholder:`2h / 90m / 30分钟,留空不带`,onChange:n=>{t({...e,duration:n.target.value}),a()}}),(0,X.jsx)(`input`,{className:`mdw-goal-prompt`,value:e.prompt,placeholder:`附加要求(可选,随 check 指令一起固化)`,onChange:n=>{t({...e,prompt:n.target.value}),a()}})]}):(0,X.jsxs)(`span`,{className:`mdw-goal-ro mono`,title:r?.prompt||`已领取计时,声明不可改`,children:[r?.duration||`—`,` · 已领取计时`]}),r&&o!=null?(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:i,title:`查看时间目标的每轮 check 记录`,children:`查看每轮 check 日志`}):null]}):null}}function Ie({historyId:e,historyNode:t,closeBesideSelf:n}){let r={origin:`起点`,reopen:`反馈`,comment:`评论`}[t?.kind]||`节点`,i=t?T(t.text||``,t.attachments||[]):``;return(0,X.jsxs)(`div`,{className:`mdw is-beside`,children:[(0,X.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,X.jsxs)(`span`,{className:`mdw-beside-lab`,children:[`链节点 · `,r,` #`,e]}),(0,X.jsx)(`span`,{className:`grow`}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭`,"aria-label":`关闭`,onClick:n,children:`×`})]}),(0,X.jsx)(`div`,{className:`mdw-hist-ro`,children:t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mdw-hist-meta`,children:[(0,X.jsx)(`span`,{children:t.at||`—`}),t.quote?(0,X.jsxs)(`span`,{children:[`锚定:`,t.quote.slice(0,80)]}):null,t.feedback?(0,X.jsxs)(`span`,{children:[`反馈:`,t.feedback.slice(0,80)]}):null,t.summary?(0,X.jsxs)(`span`,{children:[`上轮总结:`,t.summary.slice(0,80)]}):null]}),(0,X.jsx)(`article`,{className:`md-body`,dangerouslySetInnerHTML:{__html:i||`<p class="muted">(空)</p>`}})]}):(0,X.jsxs)(`div`,{className:`muted`,children:[`找不到链节点 #`,e]})})]})}function Le({boardCtx:e,docFm:t,goalEditable:n,doc:r,id:i,markDirty:a}){return e?(0,X.jsxs)(`div`,{className:`mdw-goal`,children:[(0,X.jsx)(`span`,{className:`mdw-goal-lab`,title:`归属项目(限本组成员):决定提交进哪个项目的队列;由组面板「新增任务」创建时自动携带本组语义`,children:`归属项目`}),n?(0,X.jsx)(`select`,{className:`mdw-proj-pick`,value:t.project||``,onChange:n=>{I(i,{body:p(r.body,{...t,board:e.board.id,project:n.target.value})}),a()},children:e.members.map(e=>(0,X.jsx)(`option`,{value:e.key,children:e.name},e.key))}):(0,X.jsx)(`span`,{className:`mdw-proj-ro`,title:`归属项目(在本组创建时写入,随任务走)`,children:(e.members.find(e=>e.key===t.project)||{}).name||t.project||`—`})]}):null}function Re({task:e,app:t,groupAnchored:n,groupId:r,isGlobal:i,dirKey:a}){return(0,X.jsx)(`div`,{className:`mdw`,children:(0,X.jsxs)(`div`,{className:`pad stack`,children:[(0,X.jsx)(`div`,{children:(0,X.jsxs)(`strong`,{children:[`找不到任务 #`,e]})}),(0,X.jsx)(`div`,{className:`hint`,children:`它可能已被删除(软删除可用 nx-kv localtask task restore 恢复),或这个深链写错了。`}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>t.onNavigate&&t.onNavigate(n?`#/group/`+encodeURIComponent(r||``):i?`#/global`:`#/dir/`+encodeURIComponent(a||``)),children:`回到目录`})})]})})}function ze({onClose:e}){return(0,X.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,X.jsx)(`span`,{className:`mdw-beside-lab`,children:`原文(旁路)`}),(0,X.jsx)(`span`,{className:`grow`}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭原文面板`,"aria-label":`关闭原文面板`,onClick:e,children:`×`})]})}function Be({dirKey:e,groupId:t,task:i,beside:o=!1,tabId:s,model:c,historyId:f=null}){let m=d()||{},_=a(),{dialog:x,node:C}=n(),w=m.rows||[],D=m.refreshLocal,j=m.tpl,M=!(!t||e),R=(0,q.useMemo)(()=>M?O(w,m.repoData&&m.repoData.boards||[],t,i):null,[M,w,m.repoData,t,i]),z=R&&R.topic&&R.topic.key||e||``,V=!M&&(!z||z===`__GLOBAL__`),H=P(i),ne=F(M&&H?t:z),U=L(ne,i),W=(0,q.useMemo)(()=>M?R&&R.topic||null:V?w.find(e=>e.isGlobal)||null:w.find(e=>e.key===z)||null,[w,z,V,M,R]),G=(0,q.useMemo)(()=>(W?.tasks||[]).find(e=>String(e.id)===String(i))||null,[W,i]),K=N(),J=K[U]||null,Y=J&&J.mode===`edit`?`edit`:`split`,{dockOpen:ie,setDockOpen:ae,dockTab:oe,dockH:ce,dockRef:le,dockMax:ue,showDockTab:de,onDockDragStart:fe,toggleDockMax:pe}=Ce(),{goalDraft:me,setGoalDraft:ge,goal:ve,goalEditable:be,declaredGoal:xe,goalLog:Me,loadGoalLog:Be,canShowGoalLog:Ve}=we({id:U,isDraft:H,topicKey:z,task:i,taskRow:G}),{chainNodes:He,historyNode:Ue,isChainTip:We,latestChild:Ge,openLatestRound:Ke,openHistoryBeside:qe}=Te({isDraft:H,task:i,taskRow:G,topicKey:z,topic:W,isGlobal:V,groupAnchored:M,groupId:t,app:m,model:c,historyId:f,toast:_}),{selMenu:Z,setSelMenu:Je,lastSel:Ye,placeSelMenu:Xe,onEditorTextSel:Ze,closeSelMenu:Qe}=Ee({id:U}),{ackOpen:$e,setAckOpen:et,ackOverflow:tt,reviewSumRef:nt,ackLong:rt}=De({id:U,taskRow:G,dockTab:oe,dockOpen:ie}),[it,at]=(0,q.useState)(null),[ot,st]=(0,q.useState)(!1),[ct,lt]=(0,q.useState)(!1),[ut,dt]=(0,q.useState)(!1),ft=(0,q.useRef)(null),pt=(0,q.useRef)(null),mt=(0,q.useRef)(null),ht=(0,q.useRef)(null),gt=(0,q.useRef)(null),_t=(0,q.useRef)(null),vt=(0,q.useRef)(new Map),yt=(0,q.useMemo)(()=>J?T(g(J.body),J.attachments):``,[J]),bt=(0,q.useMemo)(()=>G?.roundSummary?T(G.roundSummary):``,[G?.roundSummary]),xt=(0,q.useMemo)(()=>J?se(J.body):[],[J&&J.body]),[St,Ct]=(0,q.useState)(null);(0,q.useEffect)(()=>{let e=ht.current;if(!e)return;let t=()=>e.closest(`.mdw-lp`)||e.closest(`.mdw-preview`)||null;Ct(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Ct(t())):null;return n?.observe(e,{childList:!0,subtree:!0}),()=>n?.disconnect()},[J&&J.mode]);let wt=(0,q.useCallback)(e=>e().catch(e=>_(String(e.message||e))),[_]),Q=(0,q.useCallback)(()=>dt(!0),[]),{docFm:Tt,parentRef:$,boardCtx:Et}=Ae({doc:J,beside:o,topicKey:z,topic:W,task:i,app:m});(0,q.useEffect)(()=>{K[U]||(H?A(U,{title:``,body:j?M?p(j.defaultBody(),{board:t}):j.defaultBody():``}):G&&A(U,{title:E(G.text),body:G.text}))},[U,H,G,M,t]);let{composeText:Dt,submit:Ot,importMd:kt,delTask:At,canClosePending:jt,closeTask:Mt,addFiles:Nt,newTask:Pt,cloneCur:Ft,forkCur:It,openProgress:Lt,openAttachPanel:Rt}=Oe({doc:J,id:U,isDraft:H,task:i,taskRow:G,topicKey:z,topic:W,isGlobal:V,boardCtx:Et,docFm:Tt,groupAnchored:M,groupId:t,rows:w,app:m,model:c,tabId:s,tpl:j,refreshLocal:D,markDirty:Q,histRef:vt,editorApiRef:_t,attachAreaRef:mt,setDirty:dt,goal:ve,goalEditable:be,declaredGoal:xe,guard:wt,dialog:x,showDockTab:de}),{openFeedback:zt,submitCommentInPlace:Bt,openCommentFromToolbar:Vt}=ke({doc:J,isDraft:H,task:i,taskRow:G,topicKey:z,topic:W,isGlobal:V,dirKey:e,groupAnchored:M,groupId:t,app:m,model:c,tabId:s,refreshLocal:D,closeSelMenu:Qe,lastSel:Ye,selMenu:Z,dirty:ut,setDirty:dt,guard:wt}),Ht=(0,q.useCallback)(()=>{de(`check`),Be()},[de,Be]),{goalBadge:Ut,goalMenu:Wt}=Fe({goal:ve,goalDraft:me,setGoalDraft:ge,goalEditable:be,declaredGoal:xe,openGoalLog:Ht,markDirty:Q,task:i}),Gt=(0,q.useCallback)(()=>{at({busy:!0});let e={cwd:V?W?.cwd||void 0:W?.cwd,key:V?k:z,...H?{text:Dt((J?.title||``).trim()||`未命名任务`,J?.body||``)}:{id:Number(i)}};r(`/api/localtasks/preview`,{method:`POST`,body:e}).then(e=>at({data:e})).catch(e=>at({error:String(e.message||e)}))},[V,W?.cwd,z,H,J?.title,J?.body,i,Dt]),Kt=(e,t=`typing`)=>{if(!J)return;b(vt.current,U,{title:J.title,body:J.body},t),Q();let n={title:e};Y!==`split`&&/^# (?!#)/m.test(J.body)&&(n.body=J.body.replace(/^# (?!#).+$/m,`# ${e||`未命名任务`}`)),I(U,n)},qt=(e,t=`op`)=>{if(!J)return;b(vt.current,U,{title:J.title,body:J.body},t),Q();let n={body:e};Y!==`split`&&(n.title=E(e)),I(U,n)},Jt=()=>{if(!J)return;let e=v(vt.current,U,{title:J.title,body:J.body});e&&(I(U,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>_t.current?.caretFromDiff?.(J.body,e.body)))},Yt=()=>{if(!J)return;let e=S(vt.current,U,{title:J.title,body:J.body});e&&(I(U,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>_t.current?.caretFromDiff?.(J.body,e.body)))},Xt=e=>{if(!J||Y===`edit`||e.target.closest?.(`#mdw-sel-menu`)||e.target.closest?.(`textarea`))return;let t=window.getSelection(),n=(t&&String(t)).trim();if(!n||n.length<1){Je(null);return}if(!ht.current?.contains(t.anchorNode)){Je(null);return}let r=e=>e?.nodeType===3?e.parentElement:e,i=r(t.anchorNode)?.closest?.(`.mdw-lp-block`),a=r(t.focusNode)?.closest?.(`.mdw-lp-block`),o=null;if(i&&a&&i!==a&&ht.current?.contains(a)){let e=Number(i.getAttribute(`data-i`)),t=Number(a.getAttribute(`data-i`));Number.isInteger(e)&&Number.isInteger(t)&&e!==t&&(o=[Math.min(e,t),Math.max(e,t)])}let s=t.getRangeAt(0),c=s.getClientRects(),l=c.length?c[c.length-1]:s.getBoundingClientRect();Xe(`task`,n,l.right-60,l.bottom+8,o?{blockRange:o}:{})},Zt=(0,q.useCallback)(()=>{if(!$){_(`这条任务没有可定位的原文`);return}let e=c||m.model;e&&l(e,{component:`page`,name:$.name||`原文 ${$.task}`,config:{dirKey:$.dirKey,task:String($.task)}})},[$,c,m.model,_]),Qt=(0,q.useCallback)(()=>{let e=c||m.model;e&&s&&e.doAction(u.deleteTab(s))},[c,m.model,s]),$t=e=>{pt.current.accept=e,pt.current?.click()};return(0,q.useEffect)(()=>{if(!$||o)return;let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&String(e.key||``).toLowerCase()===`o`&&(e.preventDefault(),Zt())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[$,o,Zt]),f==null?J?(0,X.jsxs)(`div`,{className:`mdw${o?` is-beside`:``}`,"data-mode":Y,onMouseUp:Xt,children:[C,it&&(0,X.jsx)(je,{state:it,onClose:()=>at(null)}),(0,X.jsx)(Se,{open:ct,nodes:He,onOpenNode:qe,onClose:()=>lt(!1)}),o&&(0,X.jsx)(ze,{onClose:Qt}),(0,X.jsxs)(`div`,{className:`mdw-main`,children:[(0,X.jsxs)(`div`,{className:`mdw-top`,children:[(0,X.jsx)(te,{}),(0,X.jsxs)(`div`,{className:`mdw-head`,children:[(0,X.jsx)(`div`,{className:`mdw-title`,children:H?J.title||`新 MD 任务`:J.title||`任务`}),(0,X.jsxs)(`div`,{className:`mdw-path`,children:[V?`全局任务池`:W?.cwd||W?.name||`—`,H?` / (${i})`:` / #${i}`,ut?` · 未保存`:``]})]})]}),(0,X.jsx)(Le,{boardCtx:Et,docFm:Tt,goalEditable:be,doc:J,id:U,markDirty:Q}),(0,X.jsx)(re,{mode:Y,onMode:e=>I(U,{mode:e}),showMark:Y!==`edit`,submitLabel:H?`提交为任务`:`保存并同步`,onNew:Pt,onSubmit:Ot,onChain:H?null:()=>lt(!0),onPreview:Gt,onImg:()=>$t(`image/*`),onAtt:()=>H?$t(`image/*,.pdf,.zip,.txt,.json,.csv`):Rt(),onImport:()=>ft.current?.click(),onClone:H?null:Ft,onFork:H?null:It,onComplete:jt?()=>Mt(`done`):null,onCancelTask:jt?()=>Mt(`cancel`):null,onMark:Vt,onDraft:()=>_(`草稿随页签保留(刷新后需从侧栏或页签重新打开)`),onDelete:H?null:At,onOverview:()=>m.onNavigate&&m.onNavigate(`#/overview`),onProg:Lt,onSource:$?Zt:null,onShortcuts:()=>st(!0),goalBadge:Ut,goalMenu:Wt}),(0,X.jsx)(h,{ref:ht,mode:Y,title:J.title,body:J.body,previewHtml:yt,onTitle:Kt,onBody:qt,attachments:J.attachments,docKey:U,editorApiRef:_t,onFiles:Nt,onTextSel:Ze,onSave:Ot,onUndo:Jt,onRedo:Yt,onCloseSelMenu:Qe,attachHost:H?null:{host:`task`,hostId:Number(i),hostKey:V?k:void 0,hostCwd:V?void 0:W?.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(W.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status}))}}),(0,X.jsx)(Ne,{dockOpen:ie,dockTab:oe,dockH:ce,dockRef:le,dockMax:ue,showDockTab:de,onDockDragStart:fe,toggleDockMax:pe,setDockOpen:ae,canShowGoalLog:Ve,goalLog:Me,openGoalLog:Ht,isDraft:H,task:i,topic:W,topicKey:z,isGlobal:V,doc:J,id:U,model:c,app:m,refreshLocal:D,markDirty:Q,saveDoc:I,persistAtt:B,attachAreaRef:mt,reviewBarRef:gt,reviewSumRef:nt,taskRow:G,ackOpen:$e,setAckOpen:et,ackOverflow:tt,ackLong:rt,ackHtml:bt,isChainTip:We,latestChild:Ge,openFeedback:zt,openLatestRound:Ke}),(0,X.jsx)(Pe,{dockOpen:ie,dockTab:oe,showDockTab:de,setDockOpen:ae,canShowGoalLog:Ve,goalLog:Me,openGoalLog:Ht,isDraft:H,taskRow:G})]}),(0,X.jsx)(he,{nodes:xt,scrollRoot:St}),(0,X.jsx)(_e,{at:Z,onFormat:e=>{_t.current?.format?.(e),Qe()},onCompose:()=>{let t=c||m.model;if(!t)return;let n=String(Z?.text||Ye.current||``);ee(t,{mode:`comment`,quote:n,taskLabel:i==null?``:`#`+i,taskTitle:String(J?.title||``).replace(/^#+\s*/,``),src:{dirKey:z||e||`__GLOBAL__`,task:String(i),name:`原文 #${i}`},onSubmit:e=>Bt({...e,quote:n})}),Qe()},onCopy:()=>{let e=Z?.blockRange,t=``;if(e&&J){let n=y(J.body);e[1]<n.length&&(t=n.slice(e[0],e[1]+1).filter(e=>String(e??``).trim()).join(`
9
+ `);i=G({base:n,feedback:r,ackSummary:``,feedbackHeading:W,bold:!1})}let d=await r(`/api/localtasks/reopen`,{method:`POST`,body:{...c?{key:k}:{cwd:s?.cwd},id:Number(n),...i?{text:i}:{},kind:`comment`,quote:p,feedback:f,attachments:(a||[]).map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,url:e.url||``}))}}),_=d?.key||o,v=String(d?.task?.id??n),S=String(d?.task?.text??i??``);S&&I(L(F(_),v),{title:E(S),body:S}),a?.length&&B(v,[...e?.attachments||[],...a]),m&&h&&_!==o&&m.doAction(u.updateNodeAttributes(h,{config:{dirKey:_,task:v}})),x(!1),C(`已回写评论「${y}」#${v}`),g()})},[e,n,t,c,s,o,m,h,g,_,v,b,x,S,C,w]);return{fetchServerTask:w,openFeedback:T,spawnFeedbackTask:D,submitCommentInPlace:O,openCommentFromToolbar:(0,q.useCallback)(()=>{let t=String(window.getSelection()||``).trim()||(y?.text?String(y.text):``);if(!t){C(`先划选一段再评论`);return}v.current=t;let r=m||p.model;r&&(ee(r,{mode:`comment`,quote:t,taskLabel:n==null?``:`#`+n,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),src:{dirKey:o||l||`__GLOBAL__`,task:String(n),name:`原文 #${n}`},onSubmit:e=>O({...e,quote:t})}),_())},[e,n,o,l,m,p.model,v,y,O,_,C])}}function Ae({doc:e,beside:t,topicKey:n,topic:r,task:i,app:a}){let o=(0,q.useMemo)(()=>e?m(e.body):{},[e&&e.body]);return{docFm:o,parentRef:(0,q.useMemo)(()=>{if(t)return null;let a=String(o.parent||``).trim(),s=String(o.parentDir||n||``).trim();if(a&&!/^draft/i.test(a))return{dirKey:s||n,task:a,name:`#${a}`};let c=String(e?.body||``).match(/>\s*锚定自「([^」]+)」/);if(!c)return null;let l=c[1].trim(),u=(r?.tasks||[]).find(e=>String(e.id)===String(i)?!1:E(e.text||``)===l||String(e.text||``).includes(`# ${l}`));return u?{dirKey:n,task:String(u.id),name:`#${u.id}`}:null},[t,o.parent,o.parentDir,e?.body,n,r,i]),boardCtx:(0,q.useMemo)(()=>{let e=o.board;if(!e)return null;let t=(a.repoData&&a.repoData.boards||[]).find(t=>t.id===e||t.key===e||t.name===e);if(!t)return null;let n=a.repoData&&a.repoData.repos||[],r=new Map(n.map(e=>[e.key,e]));return{board:t,members:(t.repos||[]).map(e=>r.get(e.key)).filter(Boolean).map(e=>({key:e.key,name:e.name}))}},[o.board,a.repoData])}}function je({state:e,onClose:t}){let n=a(),r=e?.data,o=async()=>{try{await navigator.clipboard.writeText(String(r?.rendered||``)),n(`已复制原文`)}catch{n(`复制失败(剪贴板不可用)`)}},s=r?.switches||{},c=r?[`ack ${s.ack?.on?`开(${s.ack.count} 条)`:`关`}`,`交付上下文 ${s.deliveryTemplate?.custom?`自定义`:`内置默认`}`,`持续 get ${r.getLoop?.enabled?`开(${r.getLoop.waitMinutes} 分钟)`:`关`}`].join(` · `):``,l=r?`预览:agent 执行 get 会收到的提示词${r.task?.id?` · #${r.task.id}`:` · 草稿`}`:`预览:agent 执行 get 会收到的提示词`;return(0,X.jsxs)(i,{title:l,size:`wide`,onClose:t,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mdw-prev-hint`,children:`与 CLI 取任务共用同一份排版;不含「已取得下一条任务…」头部行。`}),(0,X.jsx)(`span`,{className:`grow`}),(0,X.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:o,disabled:!r,children:`复制原文`}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:t,children:`关闭`})]}),children:[e.busy&&(0,X.jsx)(`div`,{className:`mdw-prev-note`,children:`渲染中…`}),e.error&&(0,X.jsxs)(`div`,{className:`mdw-prev-note`,children:[`预览失败:`,e.error,/接口不存在/.test(String(e.error))&&(0,X.jsx)(`div`,{className:`mdw-prev-hint`,children:`本机面板服务较旧:重启面板(结束当前 serve 进程后重新启动)即可生效,刷新页面不够。`})]}),r&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`mdw-prev-body`,children:r.rendered||``}),r.segments?.length?(0,X.jsxs)(`details`,{className:`mdw-prev-seg`,children:[(0,X.jsxs)(`summary`,{children:[`段落来源(`,r.segments.length,` 段)`]}),(0,X.jsx)(`ol`,{children:r.segments.map((e,t)=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`mdw-prev-seg-lab`,children:e.label}),(0,X.jsxs)(`span`,{className:`mdw-prev-seg-n`,children:[String(e.text||``).length,` 字`]})]},t))}),(0,X.jsx)(`div`,{className:`mdw-prev-note`,children:`改这些段去「设置 → 提示词 / 模板」;「持续 get」在项目级设置里。`})]}):(0,X.jsx)(`div`,{className:`mdw-prev-note`,children:`当前没有任何模板段:交付时就只有任务正文。`}),(0,X.jsx)(`div`,{className:`mdw-prev-switch`,children:c})]})]})}function Me(e){let t=Math.max(0,Number(e)||0);return t>=3600?`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`:t>=60?`${Math.floor(t/60)}m ${t%60}s`:`${t}s`}function Ne({dockOpen:e,dockTab:t,dockH:n,dockRef:r,dockMax:i,showDockTab:a,onDockDragStart:s,toggleDockMax:l,setDockOpen:u,canShowGoalLog:d,goalLog:f,openGoalLog:p,isDraft:m,task:h,topic:g,topicKey:_,isGlobal:v,doc:y,id:b,model:x,app:S,refreshLocal:C,markDirty:T,saveDoc:E,persistAtt:D,attachAreaRef:O,reviewBarRef:A,reviewSumRef:j,taskRow:M,ackOpen:N,setAckOpen:P,ackOverflow:F,ackLong:I,ackHtml:L,isChainTip:R,latestChild:z,openFeedback:B,openLatestRound:V}){return e?(0,X.jsxs)(`div`,{className:`mdw-dock`,ref:r,style:{height:`${n}px`},children:[(0,X.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:s,onDoubleClick:l}),(0,X.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,X.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`attach`,className:`mdw-dock-tab${t===`attach`?` is-on`:``}`,onClick:()=>a(`attach`),children:`附件`}),d?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`check`,className:`mdw-dock-tab${t===`check`?` is-on`:``}`,onClick:p,children:[`check`,(0,X.jsx)(`span`,{className:`mdw-dock-tab-num`,children:f.data?.count??0})]}):null,(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`feedback`,className:`mdw-dock-tab${t===`feedback`?` is-on`:``}`,onClick:()=>a(`feedback`),children:`反馈`})]}),(0,X.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,X.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:l,title:i?`还原面板高度`:`最大化面板高度`,"aria-label":i?`还原面板高度`:`最大化面板高度`,children:(0,X.jsx)(o,{name:i?`collapse`:`expand`})}),(0,X.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>u(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,X.jsx)(o,{name:`x`})})]})]}),(0,X.jsxs)(`div`,{className:`mdw-dock-body`,children:[t===`attach`?m?(0,X.jsx)(H,{attachments:y.attachments,onRemove:e=>{let t=(y.attachments||[]).filter(t=>t.id!==e);T(),E(b,{attachments:t}),m||D(h,t)}}):g?(0,X.jsx)(K,{ref:O,host:`task`,hostId:Number(h),hostKey:v?k:void 0,hostCwd:v?void 0:g.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(g.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status})),onChanged:C,onOpenTask:e=>{S.openPage&&e&&e.seq!=null&&S.openPage({dirKey:e.key||_,task:String(e.seq),name:`#${e.seq}`})},onOpenDoc:e=>{let t=w(e);x&&t&&c(x,{component:`doc`,name:e.split(`/`).pop()||e,config:{docId:t},location:`center`})}}):(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`没有可挂载附件的上下文。`}):null,t===`check`?(0,X.jsxs)(`div`,{className:`mdw-dock-check`,children:[f.busy&&!f.data?(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,f.error?(0,X.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,f.error]}):null,f.data?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mdw-dock-meta mono`,children:[`时间目标 ${f.data.duration||`—`}`,f.data.startedAt?` · 开始 ${f.data.startedAt}`:``,f.data.deadline?` · 截止 ${f.data.deadline}`:` · 尚未开始计时`,f.data.archived?` · 已归档`:``,` · ${f.data.count||0} 轮`]}),(f.data.count||0)>0?(0,X.jsx)(`div`,{className:`mdw-goal-log`,children:f.data.entries.map((e,t)=>(0,X.jsxs)(`div`,{className:`mdw-goal-log-row`,children:[(0,X.jsxs)(`div`,{className:`mdw-goal-log-head mono`,children:[`R`,t+1,` · `,e.checkedAt,` · `,e.reached?`已到点`:`未到点`,` · 已用`,` `,Me(e.elapsedSec),` · 剩余 `,Me(e.remainingSec)]}),e.summary?(0,X.jsx)(`div`,{className:`mdw-goal-log-body`,children:e.summary}):null,e.progress?(0,X.jsx)(`div`,{className:`mdw-goal-log-prog`,children:e.progress}):null]},`${e.checkedAt}-${t}`))}):(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有 check 记录——任务领取后每轮 check 会出现在这里。`})]}):null]}):null,t===`feedback`?!m&&M?.completedAt?(0,X.jsxs)(`div`,{className:`mdw-review`,ref:A,children:[(0,X.jsxs)(`div`,{className:`mdw-review-main`,children:[(0,X.jsx)(`span`,{className:`mdw-review-badge`,children:`已完成 · 等待验收`}),(0,X.jsx)(`span`,{className:`mdw-review-at mono`,children:M.completedAt}),M.roundSummary?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{ref:j,className:`mdw-review-sum${N?` is-open`:``}`,title:N||!(F||I)?`agent 的完成总结(ack)`:`点击下方展开全文`,dangerouslySetInnerHTML:{__html:L}}),(F||I||N)&&(0,X.jsx)(`button`,{type:`button`,className:`mdw-review-more`,onClick:()=>P(e=>!e),children:N?`收起`:`展开全文`})]}):null]}),(0,X.jsx)(`div`,{className:`mdw-review-acts`,children:R?(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:B,title:`新开一条任务携带反馈(原任务不动)`,children:`反馈`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mdw-review-later`,title:`这条任务已有后续轮次——在旧轮次上反馈会把链分叉,请到最新一轮反馈`,children:`已进入后续轮次`}),z?(0,X.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:V,title:`到最新一轮 #${z.id} 反馈`,children:[`去最新一轮 #`,z.id]}):null]})})]}):(0,X.jsx)(`div`,{className:`mdw-dock-empty`,children:`任务完成后,agent 的完成总结会显示在这里。`}):null]})]}):null}function Pe({dockOpen:e,dockTab:t,showDockTab:n,setDockOpen:r,canShowGoalLog:i,goalLog:a,openGoalLog:s,isDraft:c,taskRow:l}){return(0,X.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`attach`?` is-on`:``}`,onClick:()=>n(`attach`),title:`附件(点击展开信息面板)`,children:[(0,X.jsx)(o,{name:`list`}),(0,X.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`})]}),i?(0,X.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`check`?` is-on`:``}`,onClick:s,title:`时间目标每轮 check(点击展开信息面板)`,children:[(0,X.jsx)(o,{name:`clock`}),(0,X.jsx)(`span`,{className:`mdw-sbar-lab`,children:`check`}),(0,X.jsx)(`span`,{className:`mdw-sbar-num`,children:a.data?.count??0})]}):null,(0,X.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${e&&t===`feedback`?` is-on`:``}`,onClick:()=>n(`feedback`),title:`完成总结 / 反馈(点击展开信息面板)`,children:[(0,X.jsx)(o,{name:`edit`}),(0,X.jsx)(`span`,{className:`mdw-sbar-lab`,children:`反馈`})]}),(0,X.jsx)(`span`,{className:`mdw-sbar-grow`}),!c&&l?(0,X.jsx)(`span`,{className:`mdw-sbar-stat`,title:`任务状态`,children:(0,X.jsx)(z,{t:l})}):null,(0,X.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${e?` is-open`:``}`,onClick:()=>r(e=>!e),title:e?`收起信息面板`:`展开信息面板`,"aria-expanded":e,"aria-label":e?`收起信息面板`:`展开信息面板`,children:(0,X.jsx)(o,{name:`chevron`})})]})}function Fe({goal:e,setGoalDraft:t,goalEditable:n,declaredGoal:r,openGoalLog:i,markDirty:a,task:o}){let s=(e.duration||``).trim(),c=(e.prompt||``).trim();return{goalBadge:s||c?{label:`⏱ ${s||`目标`}`,title:c||(n?`任务级时间目标(在「更多」里设置;领取即计时)`:`已领取计时,声明不可改`)}:null,goalMenu:n||r?(0,X.jsxs)(`div`,{className:`mdw-goal-menu`,children:[(0,X.jsx)(`div`,{className:`mdw-goal-menu-lab`,children:`时间目标`}),n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{className:`mdw-goal-dur mono`,value:e.duration,placeholder:`2h / 90m / 30分钟,留空不带`,onChange:n=>{t({...e,duration:n.target.value}),a()}}),(0,X.jsx)(`input`,{className:`mdw-goal-prompt`,value:e.prompt,placeholder:`附加要求(可选,随 check 指令一起固化)`,onChange:n=>{t({...e,prompt:n.target.value}),a()}})]}):(0,X.jsxs)(`span`,{className:`mdw-goal-ro mono`,title:r?.prompt||`已领取计时,声明不可改`,children:[r?.duration||`—`,` · 已领取计时`]}),r&&o!=null?(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:i,title:`查看时间目标的每轮 check 记录`,children:`查看每轮 check 日志`}):null]}):null}}function Ie({historyId:e,historyNode:t,closeBesideSelf:n}){let r={origin:`起点`,reopen:`反馈`,comment:`评论`}[t?.kind]||`节点`,i=t?T(t.text||``,t.attachments||[]):``;return(0,X.jsxs)(`div`,{className:`mdw is-beside`,children:[(0,X.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,X.jsxs)(`span`,{className:`mdw-beside-lab`,children:[`链节点 · `,r,` #`,e]}),(0,X.jsx)(`span`,{className:`grow`}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭`,"aria-label":`关闭`,onClick:n,children:`×`})]}),(0,X.jsx)(`div`,{className:`mdw-hist-ro`,children:t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mdw-hist-meta`,children:[(0,X.jsx)(`span`,{children:t.at||`—`}),t.quote?(0,X.jsxs)(`span`,{children:[`锚定:`,t.quote.slice(0,80)]}):null,t.feedback?(0,X.jsxs)(`span`,{children:[`反馈:`,t.feedback.slice(0,80)]}):null,t.summary?(0,X.jsxs)(`span`,{children:[`上轮总结:`,t.summary.slice(0,80)]}):null]}),(0,X.jsx)(`article`,{className:`md-body`,dangerouslySetInnerHTML:{__html:i||`<p class="muted">(空)</p>`}})]}):(0,X.jsxs)(`div`,{className:`muted`,children:[`找不到链节点 #`,e]})})]})}function Le({boardCtx:e,docFm:t,goalEditable:n,doc:r,id:i,markDirty:a}){return e?(0,X.jsxs)(`div`,{className:`mdw-goal`,children:[(0,X.jsx)(`span`,{className:`mdw-goal-lab`,title:`归属项目(限本组成员):决定提交进哪个项目的队列;由组面板「新增任务」创建时自动携带本组语义`,children:`归属项目`}),n?(0,X.jsx)(`select`,{className:`mdw-proj-pick`,value:t.project||``,onChange:n=>{I(i,{body:p(r.body,{...t,board:e.board.id,project:n.target.value})}),a()},children:e.members.map(e=>(0,X.jsx)(`option`,{value:e.key,children:e.name},e.key))}):(0,X.jsx)(`span`,{className:`mdw-proj-ro`,title:`归属项目(在本组创建时写入,随任务走)`,children:(e.members.find(e=>e.key===t.project)||{}).name||t.project||`—`})]}):null}function Re({task:e,app:t,groupAnchored:n,groupId:r,isGlobal:i,dirKey:a}){return(0,X.jsx)(`div`,{className:`mdw`,children:(0,X.jsxs)(`div`,{className:`pad stack`,children:[(0,X.jsx)(`div`,{children:(0,X.jsxs)(`strong`,{children:[`找不到任务 #`,e]})}),(0,X.jsx)(`div`,{className:`hint`,children:`它可能已被删除(软删除可用 nx-kv localtask task restore 恢复),或这个深链写错了。`}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>t.onNavigate&&t.onNavigate(n?`#/group/`+encodeURIComponent(r||``):i?`#/global`:`#/dir/`+encodeURIComponent(a||``)),children:`回到目录`})})]})})}function ze({onClose:e}){return(0,X.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,X.jsx)(`span`,{className:`mdw-beside-lab`,children:`原文(旁路)`}),(0,X.jsx)(`span`,{className:`grow`}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭原文面板`,"aria-label":`关闭原文面板`,onClick:e,children:`×`})]})}function Be({dirKey:e,groupId:t,task:i,beside:o=!1,tabId:s,model:c,historyId:f=null}){let m=d()||{},_=a(),{dialog:x,node:C}=n(),w=m.rows||[],D=m.refreshLocal,j=m.tpl,M=!(!t||e),R=(0,q.useMemo)(()=>M?O(w,m.repoData&&m.repoData.boards||[],t,i):null,[M,w,m.repoData,t,i]),z=R&&R.topic&&R.topic.key||e||``,V=!M&&(!z||z===`__GLOBAL__`),H=P(i),ne=F(M&&H?t:z),U=L(ne,i),W=(0,q.useMemo)(()=>M?R&&R.topic||null:V?w.find(e=>e.isGlobal)||null:w.find(e=>e.key===z)||null,[w,z,V,M,R]),G=(0,q.useMemo)(()=>(W?.tasks||[]).find(e=>String(e.id)===String(i))||null,[W,i]),K=N(),J=K[U]||null,Y=J&&J.mode===`edit`?`edit`:`split`,{dockOpen:ie,setDockOpen:ae,dockTab:oe,dockH:ce,dockRef:le,dockMax:ue,showDockTab:de,onDockDragStart:fe,toggleDockMax:pe}=Ce(),{goalDraft:me,setGoalDraft:ge,goal:ve,goalEditable:be,declaredGoal:xe,goalLog:Me,loadGoalLog:Be,canShowGoalLog:Ve}=we({id:U,isDraft:H,topicKey:z,task:i,taskRow:G}),{chainNodes:He,historyNode:Ue,isChainTip:We,latestChild:Ge,openLatestRound:Ke,openHistoryBeside:qe}=Te({isDraft:H,task:i,taskRow:G,topicKey:z,topic:W,isGlobal:V,groupAnchored:M,groupId:t,app:m,model:c,historyId:f,toast:_}),{selMenu:Z,setSelMenu:Je,lastSel:Ye,placeSelMenu:Xe,onEditorTextSel:Ze,closeSelMenu:Qe}=Ee({id:U}),{ackOpen:$e,setAckOpen:et,ackOverflow:tt,reviewSumRef:nt,ackLong:rt}=De({id:U,taskRow:G,dockTab:oe,dockOpen:ie}),[it,at]=(0,q.useState)(null),[ot,st]=(0,q.useState)(!1),[ct,lt]=(0,q.useState)(!1),[ut,dt]=(0,q.useState)(!1),ft=(0,q.useRef)(null),pt=(0,q.useRef)(null),mt=(0,q.useRef)(null),ht=(0,q.useRef)(null),gt=(0,q.useRef)(null),_t=(0,q.useRef)(null),vt=(0,q.useRef)(new Map),[yt,bt]=(0,q.useState)([]);(0,q.useEffect)(()=>{let e=!0,t=G;if(!t||!t.id)return;let n=new URLSearchParams({id:String(t.id)});return z?n.set(`key`,z):t.cwd&&n.set(`cwd`,t.cwd),r(`/api/localtasks/attachments?${n.toString()}`).then(t=>{e&&bt(t&&(t.attachments||t.data?.attachments)||[])}).catch(()=>{e&&bt([])}),()=>{e=!1}},[G,z]);let xt=(0,q.useMemo)(()=>J?T(g(J.body),yt.length?yt:J.attachments):``,[J,yt]),St=(0,q.useMemo)(()=>G?.roundSummary?T(G.roundSummary):``,[G?.roundSummary]),Ct=(0,q.useMemo)(()=>J?se(J.body):[],[J&&J.body]),[wt,Tt]=(0,q.useState)(null);(0,q.useEffect)(()=>{let e=ht.current;if(!e)return;let t=()=>e.closest(`.mdw-lp`)||e.closest(`.mdw-preview`)||null;Tt(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Tt(t())):null;return n?.observe(e,{childList:!0,subtree:!0}),()=>n?.disconnect()},[J&&J.mode]);let Et=(0,q.useCallback)(e=>e().catch(e=>_(String(e.message||e))),[_]),Q=(0,q.useCallback)(()=>dt(!0),[]),{docFm:Dt,parentRef:$,boardCtx:Ot}=Ae({doc:J,beside:o,topicKey:z,topic:W,task:i,app:m});(0,q.useEffect)(()=>{K[U]||(H?A(U,{title:``,body:j?M?p(j.defaultBody(),{board:t}):j.defaultBody():``}):G&&A(U,{title:E(G.text),body:G.text}))},[U,H,G,M,t]);let{composeText:kt,submit:At,importMd:jt,delTask:Mt,canClosePending:Nt,closeTask:Pt,addFiles:Ft,newTask:It,cloneCur:Lt,forkCur:Rt,openProgress:zt,openAttachPanel:Bt}=Oe({doc:J,id:U,isDraft:H,task:i,taskRow:G,topicKey:z,topic:W,isGlobal:V,boardCtx:Ot,docFm:Dt,groupAnchored:M,groupId:t,rows:w,app:m,model:c,tabId:s,tpl:j,refreshLocal:D,markDirty:Q,histRef:vt,editorApiRef:_t,attachAreaRef:mt,setDirty:dt,goal:ve,goalEditable:be,declaredGoal:xe,guard:Et,dialog:x,showDockTab:de}),{openFeedback:Vt,submitCommentInPlace:Ht,openCommentFromToolbar:Ut}=ke({doc:J,isDraft:H,task:i,taskRow:G,topicKey:z,topic:W,isGlobal:V,dirKey:e,groupAnchored:M,groupId:t,app:m,model:c,tabId:s,refreshLocal:D,closeSelMenu:Qe,lastSel:Ye,selMenu:Z,dirty:ut,setDirty:dt,guard:Et}),Wt=(0,q.useCallback)(()=>{de(`check`),Be()},[de,Be]),{goalBadge:Gt,goalMenu:Kt}=Fe({goal:ve,goalDraft:me,setGoalDraft:ge,goalEditable:be,declaredGoal:xe,openGoalLog:Wt,markDirty:Q,task:i}),qt=(0,q.useCallback)(()=>{at({busy:!0});let e={cwd:V?W?.cwd||void 0:W?.cwd,key:V?k:z,...H?{text:kt((J?.title||``).trim()||`未命名任务`,J?.body||``)}:{id:Number(i)}};r(`/api/localtasks/preview`,{method:`POST`,body:e}).then(e=>at({data:e})).catch(e=>at({error:String(e.message||e)}))},[V,W?.cwd,z,H,J?.title,J?.body,i,kt]),Jt=(e,t=`typing`)=>{if(!J)return;b(vt.current,U,{title:J.title,body:J.body},t),Q();let n={title:e};Y!==`split`&&/^# (?!#)/m.test(J.body)&&(n.body=J.body.replace(/^# (?!#).+$/m,`# ${e||`未命名任务`}`)),I(U,n)},Yt=(e,t=`op`)=>{if(!J)return;b(vt.current,U,{title:J.title,body:J.body},t),Q();let n={body:e};Y!==`split`&&(n.title=E(e)),I(U,n)},Xt=()=>{if(!J)return;let e=v(vt.current,U,{title:J.title,body:J.body});e&&(I(U,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>_t.current?.caretFromDiff?.(J.body,e.body)))},Zt=()=>{if(!J)return;let e=S(vt.current,U,{title:J.title,body:J.body});e&&(I(U,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>_t.current?.caretFromDiff?.(J.body,e.body)))},Qt=e=>{if(!J||Y===`edit`||e.target.closest?.(`#mdw-sel-menu`)||e.target.closest?.(`textarea`))return;let t=window.getSelection(),n=(t&&String(t)).trim();if(!n||n.length<1){Je(null);return}if(!ht.current?.contains(t.anchorNode)){Je(null);return}let r=e=>e?.nodeType===3?e.parentElement:e,i=r(t.anchorNode)?.closest?.(`.mdw-lp-block`),a=r(t.focusNode)?.closest?.(`.mdw-lp-block`),o=null;if(i&&a&&i!==a&&ht.current?.contains(a)){let e=Number(i.getAttribute(`data-i`)),t=Number(a.getAttribute(`data-i`));Number.isInteger(e)&&Number.isInteger(t)&&e!==t&&(o=[Math.min(e,t),Math.max(e,t)])}let s=t.getRangeAt(0),c=s.getClientRects(),l=c.length?c[c.length-1]:s.getBoundingClientRect();Xe(`task`,n,l.right-60,l.bottom+8,o?{blockRange:o}:{})},$t=(0,q.useCallback)(()=>{if(!$){_(`这条任务没有可定位的原文`);return}let e=c||m.model;e&&l(e,{component:`page`,name:$.name||`原文 ${$.task}`,config:{dirKey:$.dirKey,task:String($.task)}})},[$,c,m.model,_]),en=(0,q.useCallback)(()=>{let e=c||m.model;e&&s&&e.doAction(u.deleteTab(s))},[c,m.model,s]),tn=e=>{pt.current.accept=e,pt.current?.click()};return(0,q.useEffect)(()=>{if(!$||o)return;let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&String(e.key||``).toLowerCase()===`o`&&(e.preventDefault(),$t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[$,o,$t]),f==null?J?(0,X.jsxs)(`div`,{className:`mdw${o?` is-beside`:``}`,"data-mode":Y,onMouseUp:Qt,children:[C,it&&(0,X.jsx)(je,{state:it,onClose:()=>at(null)}),(0,X.jsx)(Se,{open:ct,nodes:He,onOpenNode:qe,onClose:()=>lt(!1)}),o&&(0,X.jsx)(ze,{onClose:en}),(0,X.jsxs)(`div`,{className:`mdw-main`,children:[(0,X.jsxs)(`div`,{className:`mdw-top`,children:[(0,X.jsx)(te,{}),(0,X.jsxs)(`div`,{className:`mdw-head`,children:[(0,X.jsx)(`div`,{className:`mdw-title`,children:H?J.title||`新 MD 任务`:J.title||`任务`}),(0,X.jsxs)(`div`,{className:`mdw-path`,children:[V?`全局任务池`:W?.cwd||W?.name||`—`,H?` / (${i})`:` / #${i}`,ut?` · 未保存`:``]})]})]}),(0,X.jsx)(Le,{boardCtx:Ot,docFm:Dt,goalEditable:be,doc:J,id:U,markDirty:Q}),(0,X.jsx)(re,{mode:Y,onMode:e=>I(U,{mode:e}),showMark:Y!==`edit`,submitLabel:H?`提交为任务`:`保存并同步`,onNew:It,onSubmit:At,onChain:H?null:()=>lt(!0),onPreview:qt,onImg:()=>tn(`image/*`),onAtt:()=>H?tn(`image/*,.pdf,.zip,.txt,.json,.csv`):Bt(),onImport:()=>ft.current?.click(),onClone:H?null:Lt,onFork:H?null:Rt,onComplete:Nt?()=>Pt(`done`):null,onCancelTask:Nt?()=>Pt(`cancel`):null,onMark:Ut,onDraft:()=>_(`草稿随页签保留(刷新后需从侧栏或页签重新打开)`),onDelete:H?null:Mt,onOverview:()=>m.onNavigate&&m.onNavigate(`#/overview`),onProg:zt,onSource:$?$t:null,onShortcuts:()=>st(!0),goalBadge:Gt,goalMenu:Kt}),(0,X.jsx)(h,{ref:ht,mode:Y,title:J.title,body:J.body,previewHtml:xt,onTitle:Jt,onBody:Yt,attachments:yt.length?[...J.attachments,...yt]:J.attachments,docKey:U,editorApiRef:_t,onFiles:Ft,onTextSel:Ze,onSave:At,onUndo:Xt,onRedo:Zt,onCloseSelMenu:Qe,attachHost:H?null:{host:`task`,hostId:Number(i),hostKey:V?k:void 0,hostCwd:V?void 0:W?.cwd,allow:{file:!0,url:!0,task:!0,ref:!0},taskOptions:(W.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status}))}}),(0,X.jsx)(Ne,{dockOpen:ie,dockTab:oe,dockH:ce,dockRef:le,dockMax:ue,showDockTab:de,onDockDragStart:fe,toggleDockMax:pe,setDockOpen:ae,canShowGoalLog:Ve,goalLog:Me,openGoalLog:Wt,isDraft:H,task:i,topic:W,topicKey:z,isGlobal:V,doc:J,id:U,model:c,app:m,refreshLocal:D,markDirty:Q,saveDoc:I,persistAtt:B,attachAreaRef:mt,reviewBarRef:gt,reviewSumRef:nt,taskRow:G,ackOpen:$e,setAckOpen:et,ackOverflow:tt,ackLong:rt,ackHtml:St,isChainTip:We,latestChild:Ge,openFeedback:Vt,openLatestRound:Ke}),(0,X.jsx)(Pe,{dockOpen:ie,dockTab:oe,showDockTab:de,setDockOpen:ae,canShowGoalLog:Ve,goalLog:Me,openGoalLog:Wt,isDraft:H,taskRow:G})]}),(0,X.jsx)(he,{nodes:Ct,scrollRoot:wt}),(0,X.jsx)(_e,{at:Z,onFormat:e=>{_t.current?.format?.(e),Qe()},onCompose:()=>{let t=c||m.model;if(!t)return;let n=String(Z?.text||Ye.current||``);ee(t,{mode:`comment`,quote:n,taskLabel:i==null?``:`#`+i,taskTitle:String(J?.title||``).replace(/^#+\s*/,``),src:{dirKey:z||e||`__GLOBAL__`,task:String(i),name:`原文 #${i}`},onSubmit:e=>Ht({...e,quote:n})}),Qe()},onCopy:()=>{let e=Z?.blockRange,t=``;if(e&&J){let n=y(J.body);e[1]<n.length&&(t=n.slice(e[0],e[1]+1).filter(e=>String(e??``).trim()).join(`
10
10
 
11
- `))}navigator.clipboard?.writeText(t||Ye.current||Z?.text||``),_(`已复制`),Qe()},onDelete:Z?.blockRange?()=>{let e=Z.blockRange;_t.current?.deleteBlockRange?.(e[0],e[1])?_(`已删除 ${e[1]-e[0]+1} 个块(Ctrl+Z 可撤销)`):_(`选区已失效`),Qe()}:null}),(0,X.jsx)(`input`,{ref:pt,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&Nt(t)}}),(0,X.jsx)(`input`,{ref:ft,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&kt(t)}}),ot&&(0,X.jsx)(ye,{onClose:()=>st(!1)})]}):m.localReady===!1||H?(0,X.jsx)(`div`,{className:`mdw`,children:(0,X.jsx)(`div`,{className:`pad muted`,children:`载入中…`})}):(0,X.jsx)(Re,{task:i,app:m,groupAnchored:M,groupId:t,isGlobal:V,dirKey:e}):(0,X.jsx)(Ie,{historyId:f,historyNode:Ue,closeBesideSelf:Qt})}export{Be as default};
11
+ `))}navigator.clipboard?.writeText(t||Ye.current||Z?.text||``),_(`已复制`),Qe()},onDelete:Z?.blockRange?()=>{let e=Z.blockRange;_t.current?.deleteBlockRange?.(e[0],e[1])?_(`已删除 ${e[1]-e[0]+1} 个块(Ctrl+Z 可撤销)`):_(`选区已失效`),Qe()}:null}),(0,X.jsx)(`input`,{ref:pt,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&Ft(t)}}),(0,X.jsx)(`input`,{ref:ft,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&jt(t)}}),ot&&(0,X.jsx)(ye,{onClose:()=>st(!1)})]}):m.localReady===!1||H?(0,X.jsx)(`div`,{className:`mdw`,children:(0,X.jsx)(`div`,{className:`pad muted`,children:`载入中…`})}):(0,X.jsx)(Re,{task:i,app:m,groupAnchored:M,groupId:t,isGlobal:V,dirKey:e}):(0,X.jsx)(Ie,{historyId:f,historyNode:Ue,closeBesideSelf:en})}export{Be as default};
@@ -1 +1 @@
1
- import{g as e,h as t,p as n,y as r}from"./task-status-BnymQMTw.js";import{n as i,v as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,r as u,t as d,v as f}from"./md-history-DB5forf2.js";import{i as p,t as m}from"./index-BrAIkzFc.js";import{t as h}from"./route-crumb-C8JzPIax.js";var g=r(e(),1),_=t(),v=e=>`tpl:${e||`new`}`;function y({templateId:e,initialName:t,initialBody:r,isNew:i,onSave:a,onClose:o,busy:p}){let m=n(),[y,b]=(0,g.useState)(t||``),[x,S]=(0,g.useState)(r||``),[C,w]=(0,g.useState)(`split`),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(new Map),k=v(i?`new`:e),A=(0,g.useMemo)(()=>f(x||``),[x]),j=(e,t,n=`typing`)=>{l(O.current,k,{title:y,body:x},n),b(e),S(t),E(!0)},M=(e,t=`typing`)=>j(e,x,t),N=(e,t=`op`)=>j(y,e,t),P=()=>{let e=c(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},F=()=>{let e=u(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},I=async()=>{if(!(y||``).trim()){m(`模板名不能为空(标题即名称)`);return}await a({name:y.trim(),body:x}),d(O.current,k),E(!1)};return(0,_.jsx)(`div`,{className:`mdw mdw-tpl-edpage`,"data-mode":C,children:(0,_.jsxs)(`div`,{className:`mdw-main`,children:[(0,_.jsxs)(`div`,{className:`mdw-top`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`mdw-head`,children:[(0,_.jsx)(`div`,{className:`mdw-title`,children:i?`新建模板`:`编辑模板`}),(0,_.jsxs)(`div`,{className:`mdw-path`,children:[`任务模板`,y?` / ${y}`:``,T?` · 未保存`:``]})]})]}),(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:(0,_.jsx)(`div`,{className:`seg`,role:`group`,"aria-label":`编辑模式`,children:[{id:`split`,label:`并排`},{id:`edit`,label:`源码`}].map(e=>(0,_.jsx)(`button`,{type:`button`,className:C===e.id?`on`:``,onClick:()=>w(e.id),children:e.label},e.id))})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`模板操作`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:p,onClick:o,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:p||!T,onClick:I,children:i?`创建`:`保存`})]})]}),(0,_.jsx)(s,{mode:C,title:y,body:x,previewHtml:A,onTitle:M,onBody:N,docKey:k,editorApiRef:D,onSave:I,onUndo:P,onRedo:F,attachments:[]})]})})}function b({config:e,model:t,tabId:r}){let s=o()||{},c=s.tpl,l=n(),[u,d]=(0,g.useState)(!1),f=e||{},v=(f.mode||(f.id?`edit`:``))===`new`,b=f.id||``,x=()=>{let e=m();if(e&&s.onNavigate){s.onNavigate(e);return}if(s.onNavigate){s.onNavigate(`#/overview`);return}if(t&&r)try{t.doAction(a.deleteTab(r))}catch{}};if(!c)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});if(!v&&!b)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad stack`,children:[(0,_.jsx)(`div`,{children:`模板在「设置 → 任务模板」管理;这里只承载全屏编辑。`}),(0,_.jsx)(`div`,{children:(0,_.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{t&&i(t,{component:`settings`,name:`设置`,config:{}}),x()},children:`打开设置`})})]})]});let S=v?null:(c.templates||[]).find(e=>e.id===b);if(!v&&!S)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad muted`,children:[`找不到模板「`,b,`」——可能已删除。`]})]});let C=async({name:e,body:t})=>{d(!0);try{if(v){let n={};Array.isArray(f.scope)&&(n.scope=f.scope),f.topic&&(n.topic=f.topic),await c.add(e,t,!1,n),l(`已创建模板`)}else await c.update(b,{name:e,body:t}),l(`已保存模板`);x()}catch(e){l(String(e.message||e))}finally{d(!1)}},w=v?f.name||``:S.name,T=v?``:p(S.body||``,S.values||{});return(0,_.jsx)(y,{templateId:b,initialName:w,initialBody:T,isNew:v,busy:u,onSave:C,onClose:x},v?`new:${f.topic||``}:${(f.scope||[]).join(`,`)}`:b)}export{b as default};
1
+ import{g as e,h as t,p as n,y as r}from"./task-status-BnymQMTw.js";import{n as i,v as a}from"./workspace-C_5X2gIr.js";import{n as o}from"./app-context-D7HAx67n.js";import{a as s,i as c,n as l,r as u,t as d,v as f}from"./md-history-C9vOgGLz.js";import{i as p,t as m}from"./index-DNB8tgNi.js";import{t as h}from"./route-crumb-BfRi1GKw.js";var g=r(e(),1),_=t(),v=e=>`tpl:${e||`new`}`;function y({templateId:e,initialName:t,initialBody:r,isNew:i,onSave:a,onClose:o,busy:p}){let m=n(),[y,b]=(0,g.useState)(t||``),[x,S]=(0,g.useState)(r||``),[C,w]=(0,g.useState)(`split`),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(new Map),k=v(i?`new`:e),A=(0,g.useMemo)(()=>f(x||``),[x]),j=(e,t,n=`typing`)=>{l(O.current,k,{title:y,body:x},n),b(e),S(t),E(!0)},M=(e,t=`typing`)=>j(e,x,t),N=(e,t=`op`)=>j(y,e,t),P=()=>{let e=c(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},F=()=>{let e=u(O.current,k,{title:y,body:x});e&&(b(e.title||``),S(e.body||``),E(!0))},I=async()=>{if(!(y||``).trim()){m(`模板名不能为空(标题即名称)`);return}await a({name:y.trim(),body:x}),d(O.current,k),E(!1)};return(0,_.jsx)(`div`,{className:`mdw mdw-tpl-edpage`,"data-mode":C,children:(0,_.jsxs)(`div`,{className:`mdw-main`,children:[(0,_.jsxs)(`div`,{className:`mdw-top`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`mdw-head`,children:[(0,_.jsx)(`div`,{className:`mdw-title`,children:i?`新建模板`:`编辑模板`}),(0,_.jsxs)(`div`,{className:`mdw-path`,children:[`任务模板`,y?` / ${y}`:``,T?` · 未保存`:``]})]})]}),(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:(0,_.jsx)(`div`,{className:`seg`,role:`group`,"aria-label":`编辑模式`,children:[{id:`split`,label:`并排`},{id:`edit`,label:`源码`}].map(e=>(0,_.jsx)(`button`,{type:`button`,className:C===e.id?`on`:``,onClick:()=>w(e.id),children:e.label},e.id))})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`模板操作`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:p,onClick:o,children:`关闭`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:p||!T,onClick:I,children:i?`创建`:`保存`})]})]}),(0,_.jsx)(s,{mode:C,title:y,body:x,previewHtml:A,onTitle:M,onBody:N,docKey:k,editorApiRef:D,onSave:I,onUndo:P,onRedo:F,attachments:[]})]})})}function b({config:e,model:t,tabId:r}){let s=o()||{},c=s.tpl,l=n(),[u,d]=(0,g.useState)(!1),f=e||{},v=(f.mode||(f.id?`edit`:``))===`new`,b=f.id||``,x=()=>{let e=m();if(e&&s.onNavigate){s.onNavigate(e);return}if(s.onNavigate){s.onNavigate(`#/overview`);return}if(t&&r)try{t.doAction(a.deleteTab(r))}catch{}};if(!c)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});if(!v&&!b)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad stack`,children:[(0,_.jsx)(`div`,{children:`模板在「设置 → 任务模板」管理;这里只承载全屏编辑。`}),(0,_.jsx)(`div`,{children:(0,_.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{t&&i(t,{component:`settings`,name:`设置`,config:{}}),x()},children:`打开设置`})})]})]});let S=v?null:(c.templates||[]).find(e=>e.id===b);if(!v&&!S)return(0,_.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,_.jsx)(h,{}),(0,_.jsxs)(`div`,{className:`pad muted`,children:[`找不到模板「`,b,`」——可能已删除。`]})]});let C=async({name:e,body:t})=>{d(!0);try{if(v){let n={};Array.isArray(f.scope)&&(n.scope=f.scope),f.topic&&(n.topic=f.topic),await c.add(e,t,!1,n),l(`已创建模板`)}else await c.update(b,{name:e,body:t}),l(`已保存模板`);x()}catch(e){l(String(e.message||e))}finally{d(!1)}},w=v?f.name||``:S.name,T=v?``:p(S.body||``,S.values||{});return(0,_.jsx)(y,{templateId:b,initialName:w,initialBody:T,isNew:v,busy:u,onSave:C,onClose:x},v?`new:${f.topic||``}:${(f.scope||[]).join(`,`)}`:b)}export{b as default};
@@ -0,0 +1 @@
1
+ import{g as e,h as t,l as n,m as r,o as i,p as a,y as o}from"./task-status-BnymQMTw.js";import{w as s}from"./workspace-C_5X2gIr.js";import{c,d as l,f as u,l as d,o as f,s as p}from"./md-history-C9vOgGLz.js";import{n as m,o as h}from"./upload-BIMbGcCB.js";var g=o(e(),1),_=t(),v={position:(e,t)=>(e.position||0)-(t.position||0)||String(e.id).localeCompare(String(t.id)),name:(e,t)=>String(e.name||``).localeCompare(String(t.name||``)),kind:(e,t)=>String(e.kind).localeCompare(String(t.kind))||String(e.name||``).localeCompare(String(t.name||``))};function y({host:e=`task`,hostId:t,hostKey:o,hostCwd:s,refId:c,allow:d={file:!0,url:!0,task:!1,ref:!1},taskOptions:y=[],docOptions:x,disabled:S=!1,disabledText:C=`提交任务后可以在这里挂附件(当前是草稿)。`,openRef:w,onChanged:T,onOpenTask:E,onOpenDoc:D}){let O=a(),{dialog:k,node:A}=n(),[j,M]=(0,g.useState)([]),[N,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(``),[L,R]=(0,g.useState)(!1),[z,B]=(0,g.useState)(!1),[V,H]=(0,g.useState)(!1),[U,W]=(0,g.useState)(`position`),[G,K]=(0,g.useState)(null),[q,J]=(0,g.useState)(null),[Y,ee]=(0,g.useState)(!1),[X,Z]=(0,g.useState)(null),Q=(0,g.useMemo)(()=>l(e,{hostId:t,hostKey:o,hostCwd:s,refId:c}),[e,t,o,s,c]),$=(0,g.useCallback)(async()=>{if(S){M([]);return}P(!0),I(``);try{let e=await Q.list();M((e.attachments||[]).map(u))}catch(e){I(String(e&&e.message||e))}finally{P(!1)}},[Q,S]);(0,g.useEffect)(()=>{$()},[$]),(0,g.useImperativeHandle)(w,()=>({open:()=>R(!0),refresh:$}),[$]),(0,g.useEffect)(()=>{if(!X)return;let e=e=>{e.key===`Escape`&&Z(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[X]);let te=(0,g.useMemo)(()=>[...j].sort(v[U]||v.position),[j,U]),ne=te.filter(e=>e.area===`inline`),re=te.filter(e=>e.area===`area`),ie=async(e,t)=>{if(S)return;let n=m(t),r=n.length?n:[...e||[]].filter(e=>e&&e.size>0);if(!r.length)return;H(!0);let i=0;for(let e of r)try{let t=await h(e,{local:!0}),n=t.fileId||t.id;if(!n)throw Error(`上传未返回 fileId`);await Q.attach({fileId:n,name:t.name}),i+=1}catch(t){O(`「${e.name||`文件`}」添加失败:${t&&t.message||t}`)}H(!1),i&&(O(`已挂到附件区 ${i} 个文件`),await $(),T?.())},ae=async n=>{if(n)try{let i=await k({title:`说明 · ${n.name}`,input:!0,placeholder:`这一行里大概是什么(交付清单会透出给 agent)`,value:n.note||``,okText:`保存说明`});if(i===null)return;let a=typeof i==`string`?i:i&&(i.value||i.note)||``,l=e===`doc`?`/api/docs/attach-note?ref=${encodeURIComponent(String(c||``))}`:`/api/localtasks/attach-note`,u=e===`doc`?{attachment:n.id,note:a}:{id:Number(t),...o?{key:o}:s?{cwd:s}:{},attachment:n.id,note:a};await r(l,{method:`PATCH`,body:u}),O(a?`已保存说明:${a}`:`已清空说明`),await $(),T?.()}catch(e){O(`改说明失败:${e&&e.message||e}`)}},oe=e=>{e&&(J(e),R(!0))},se=async e=>{let t=G;if(t){ee(!0);try{await Q.detach(t.id,!!e),K(null),O(e?`已移除并删除资源:${t.name}`:`已解除关联:${t.name}`),await $(),T?.()}catch(e){O(`移除失败:${e&&e.message||e}`)}finally{ee(!1)}}},ce=!N&&!F&&!j.length;return(0,_.jsxs)(`div`,{className:`att-area${S?` is-disabled`:``}`,onDragOver:e=>{!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),B(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||B(!1)},onDrop:e=>{B(!1),!S&&[...e.dataTransfer?.types||[]].includes(`Files`)&&(e.preventDefault(),ie(null,e))},children:[A,(0,_.jsxs)(`div`,{className:`att-area-head`+(z&&!S?` is-over`:``),children:[(0,_.jsxs)(`span`,{className:`att-area-title`,children:[`附件`,j.length?(0,_.jsx)(`span`,{className:`att-count`,children:j.length}):null,V?(0,_.jsx)(`span`,{className:`att-area-note`,children:`上传中…`}):null]}),(0,_.jsxs)(`span`,{className:`att-area-acts`,children:[j.length?(0,_.jsxs)(`select`,{className:`att-sort`,value:U,onChange:e=>W(e.target.value),"aria-label":`附件排序`,children:[(0,_.jsx)(`option`,{value:`position`,children:`按添加顺序`}),(0,_.jsx)(`option`,{value:`name`,children:`按名称`}),(0,_.jsx)(`option`,{value:`kind`,children:`按类型`})]}):null,(0,_.jsx)(`button`,{type:`button`,className:`btn ghost att-add-btn`,disabled:S,onClick:()=>R(!0),children:`添加附件`})]})]}),S?(0,_.jsx)(`div`,{className:`att-empty`,children:C}):null,N?(0,_.jsx)(`div`,{className:`att-empty`,children:`加载附件…`}):null,F?(0,_.jsxs)(`div`,{className:`att-empty att-err-text`,children:[`附件加载失败:`,F]}):null,ce?(0,_.jsx)(`div`,{className:`att-empty`,children:`还没有附件。拖文件到这里,或点「添加附件」——只挂附件区,不写正文。`}):null,ne.length?(0,_.jsxs)(`div`,{className:`att-section`,children:[(0,_.jsxs)(`div`,{className:`att-section-head`,children:[p.inline,(0,_.jsx)(`span`,{className:`att-section-hint`,children:`正文里的引用,删正文行会跟着消失`})]}),ne.map(e=>b(e,{onRemove:K,onPreview:Z,onOpenTask:E,onOpenDoc:D,onEditNote:ae,onReplace:oe,key:e.id}))]}):null,re.length?(0,_.jsxs)(`div`,{className:`att-section`,children:[(0,_.jsxs)(`div`,{className:`att-section-head`,children:[p.area,(0,_.jsx)(`span`,{className:`att-section-hint`,children:`不依赖正文,删正文行也不会丢`})]}),re.map(e=>b(e,{onRemove:K,onPreview:Z,onOpenTask:E,onOpenDoc:D,onEditNote:ae,onReplace:oe,key:e.id}))]}):null,(0,_.jsx)(f,{open:L,host:e,hostId:t,hostKey:o,hostCwd:s,refId:c,allow:d,taskOptions:y,docOptions:x,replaceAttachment:q?q.id:null,replaceNote:q&&q.note||``,onClose:()=>{R(!1),J(null)},onDone:async()=>{J(null),await $(),T?.()}}),G?(0,_.jsx)(i,{title:`移除附件`,size:`sm`,busy:Y,onClose:Y?void 0:()=>K(null),footer:(0,_.jsxs)(`div`,{className:`att-foot`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost`,disabled:Y,onClick:()=>K(null),children:`取消`}),(0,_.jsx)(`button`,{type:`button`,className:`btn`,disabled:Y,onClick:()=>se(!1),children:`只解除关联`}),(0,_.jsx)(`button`,{type:`button`,className:`btn danger`,disabled:Y,onClick:()=>se(!0),children:G.kind===`file`?`连文件一起删`:`连资源一起删`})]}),children:(0,_.jsxs)(`div`,{className:`att-confirm`,children:[(0,_.jsx)(`div`,{className:`att-confirm-name`,children:G.name}),(0,_.jsxs)(`div`,{className:`att-confirm-text`,children:[`只解除关联:从这份`,e===`task`?`任务`:`文档`,`的附件清单里移除,资源仍留在孤儿池,可被重新挂载。 连资源一起删:在本机没有其它任务/文档引用它时,删除资源行(本机文件同时删字节);仍被引用时只解除关联。`]})]})}):null,X?(0,_.jsx)(`div`,{className:`att-lightbox`,role:`dialog`,"aria-label":`图片预览`,onMouseDown:e=>{e.target===e.currentTarget&&Z(null)},children:(0,_.jsxs)(`div`,{className:`att-lightbox-card`,children:[(0,_.jsxs)(`div`,{className:`att-lightbox-head`,children:[(0,_.jsx)(`span`,{className:`att-lightbox-name`,children:X.name}),(0,_.jsx)(`a`,{className:`att-lightbox-open`,href:X.src,target:`_blank`,rel:`noreferrer`,children:`新窗口打开`}),(0,_.jsx)(`button`,{type:`button`,className:`pp-x`,"aria-label":`关闭`,onClick:()=>Z(null),children:`×`})]}),(0,_.jsx)(`img`,{className:`att-lightbox-img`,src:X.src,alt:X.name})]})}):null]})}function b(e,{onRemove:t,onPreview:n,onOpenTask:r,onOpenDoc:i,onEditNote:a,onReplace:o}){let s=e.kind===`image`?d(e.id):``;return(0,_.jsxs)(`div`,{className:`att-item att-kind-${e.kind}`,children:[e.kind===`image`?(0,_.jsx)(`button`,{type:`button`,className:`att-thumb`,onClick:()=>n({src:s,name:e.name}),title:`点击看大图`,children:(0,_.jsx)(`img`,{src:s,alt:e.name,loading:`lazy`})}):(0,_.jsx)(`span`,{className:`att-kind-badge`,children:c(e.kind)}),(0,_.jsxs)(`span`,{className:`att-item-main`,children:[e.kind===`task`?(0,_.jsx)(`button`,{type:`button`,className:`att-link`,title:`跳转到任务 #${e.targetSeq??``}`,onClick:()=>r?.({key:e.targetKey,seq:e.targetSeq}),children:e.name}):e.kind===`ref`?(0,_.jsx)(`button`,{type:`button`,className:`att-link`,title:e.locator||e.targetRef||`打开文档`,onClick:()=>i?.(e.locator||e.targetRef),children:e.name}):e.kind===`url`?(0,_.jsx)(`a`,{className:`att-link`,href:e.url,target:`_blank`,rel:`noreferrer`,title:e.url,children:e.name}):(0,_.jsx)(`span`,{className:`att-item-name`,title:e.name,children:e.name}),(0,_.jsxs)(`span`,{className:`att-item-meta`,children:[e.sizeText?(0,_.jsx)(`span`,{children:e.sizeText}):null,e.note?(0,_.jsx)(`span`,{className:`att-note`,children:e.note}):null]})]}),e.kind===`file`||e.kind===`image`?(0,_.jsxs)(`span`,{className:`att-item-acts`,children:[(0,_.jsx)(`a`,{className:`att-act`,href:d(e.id),target:`_blank`,rel:`noreferrer`,children:`打开`}),(0,_.jsx)(`a`,{className:`att-act`,href:d(e.id),download:e.name,children:`下载`})]}):null,e.kind===`ref`?(0,_.jsxs)(`span`,{className:`att-item-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`att-act`,title:`改这条绑定的一行说明(交付清单会透出)`,onClick:()=>a?.(e),children:`✎ 说明`}),(0,_.jsx)(`button`,{type:`button`,className:`att-act`,title:`换成另一篇文档(替换这条绑定)`,onClick:()=>o?.(e),children:`⇄ 更换`})]}):null,(0,_.jsx)(`button`,{type:`button`,className:`att-x`,"aria-label":`移除 ${e.name}`,onClick:()=>t(e),children:`×`})]},e.id)}var x=s(),S=[{id:`new`,label:`+ 新建页`,section:`primary`,noHide:!0},{id:`import`,label:`导入`,section:`bar`},{id:`progress`,label:`进程`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],C=[{id:`new`,label:`+ 新增任务`,section:`primary`,noHide:!0},{id:`progress`,label:`进程`,section:`bar`},{id:`addMember`,label:`添加成员`,section:`bar`},{id:`orch`,label:`编排`,section:`bar`},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`deleted`,label:`已删除任务`,section:`more`},{id:`refs`,label:`查看列表`,section:`more`}],w=[{id:`new`,label:`新任务`,section:`primary`,noHide:!0},{id:`submit`,label:`提交`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`img`,label:`插入图片`,section:`more`,menuGroup:`edit`},{id:`att`,label:`添加附件`,section:`more`,menuGroup:`edit`},{id:`import`,label:`导入`,section:`more`,menuGroup:`edit`},{id:`draft`,label:`存草稿`,section:`more`,menuGroup:`edit`},{id:`chain`,label:`任务链`,section:`more`,menuGroup:`task`},{id:`clone`,label:`克隆任务`,section:`more`,menuGroup:`task`},{id:`fork`,label:`Fork 任务`,section:`more`,menuGroup:`task`},{id:`complete`,label:`标为完成`,section:`more`,menuGroup:`task`},{id:`cancel-task`,label:`取消任务`,section:`more`,menuGroup:`task`,danger:!0},{id:`mark`,label:`评论`,section:`more`,menuGroup:`task`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`task`,danger:!0},{id:`preview`,label:`预览提示词`,section:`more`,menuGroup:`view`},{id:`overview`,label:`总览`,section:`more`,menuGroup:`view`},{id:`prog`,label:`进程`,section:`more`,menuGroup:`view`},{id:`source`,label:`原文`,section:`more`,menuGroup:`view`},{id:`shortcuts`,label:`快捷键`,section:`more`,menuGroup:`view`}],T=[{id:`save`,label:`保存`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`mode`,label:`源码模式`,section:`more`,menuGroup:`edit`},{id:`rename`,label:`重命名`,section:`more`,menuGroup:`doc`},{id:`delete`,label:`删除`,section:`more`,menuGroup:`doc`,danger:!0},{id:`list`,label:`文字列表`,section:`more`,menuGroup:`view`}],E=[{id:`add`,label:`登记仓库`,section:`primary`,noHide:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`boards`,label:`分组管理`,section:`more`,menuGroup:`manage`},{id:`refs`,label:`参考仓库管理`,section:`more`,menuGroup:`manage`},{id:`transfer`,label:`导入导出`,section:`more`,menuGroup:`manage`}],D=[{id:`edit`,label:`编辑`,section:`bar`},{id:`open`,label:`打开`,section:`bar`},{id:`del`,label:`删除`,section:`bar`,danger:!0},{id:`more`,label:`更多`,section:`bar`,noHide:!0},{id:`getloop`,label:`持续 get…`,section:`more`,menuGroup:`repo`},{id:`remote`,label:`对齐 remote`,section:`more`,menuGroup:`repo`}],O={dir:Object.fromEntries(S.map(e=>[e.id,e])),group:Object.fromEntries(C.map(e=>[e.id,e])),task:Object.fromEntries(w.map(e=>[e.id,e])),doc:Object.fromEntries(T.map(e=>[e.id,e])),repos:Object.fromEntries(E.map(e=>[e.id,e])),"repos-row":Object.fromEntries(D.map(e=>[e.id,e]))};function k(e){return e===`group`?C:e===`task`?w:e===`doc`?T:e===`repos`?E:e===`repos-row`?D:S}function A(e,t){return O[e]&&O[e][t]||{}}function j(e,t){let n=A(e,t);return String(n.section||``).startsWith(`more`)||!!n.defaultInMore}function M(e,t){return A(e,t.id).noHide?!0:t.visible===void 0?!j(e,t.id):t.visible!==!1}function N(e,t){return t.id===`more`||A(e,t.id).noHide?!1:!M(e,t)}function P(e,t){let n=k(e),r=new Set(n.map(e=>e.id)),i=new Set,a=[];for(let n of t||[]){if(!n||!n.id||!r.has(n.id)||i.has(n.id))continue;i.add(n.id);let t=A(e,n.id);a.push(t.noHide?{...n,visible:!0}:n)}for(let t of n)i.has(t.id)||a.push({id:t.id,visible:t.noHide?!0:!j(e,t.id)});let o=a.findIndex(e=>e.id===`more`);if(o>=0&&o<a.length-1){let[t]=a.splice(o,1),n=a.length;for(let t=0;t<a.length;t++)if(j(e,a[t].id)&&!M(e,a[t])){n=t;break}a.splice(n,0,t)}return a}function F(e){return P(e,k(e).map(t=>({id:t.id,visible:t.noHide?!0:!j(e,t.id)})))}var I=e=>`nx-kv-tb-${e}`;function L(e){let[t,n]=(0,g.useState)(()=>{try{let t=JSON.parse(localStorage.getItem(I(e)));if(Array.isArray(t))return P(e,t)}catch{}return F(e)});return(0,g.useEffect)(()=>{try{localStorage.setItem(I(e),JSON.stringify(t))}catch{}},[t,e]),{layout:t,setLayout:n,resetLayout:()=>n(F(e))}}function R(e,t){return!!A(e,t).lockLast}function z(e,t,n){return e.map(e=>e.id===t?{...e,...n}:e)}function B(e,t,{id:n,anchorId:r=null,after:i=!1,visible:a}){let o=t.findIndex(e=>e.id===n);if(o<0||R(e,n))return t;let s={...t[o]};a!==void 0&&(s.visible=A(e,n).noHide?!0:!!a);let c=t.filter((e,t)=>t!==o),l;if(r===n)l=o;else if(r){let e=c.findIndex(e=>e.id===r);l=e<0?c.length:e+ +!!i}else{let e=c.findIndex(e=>e.id===`more`);l=e>=0?e:c.length}let u=c.findIndex(t=>R(e,t.id));u>=0&&l>u&&(l=u);let d=c.slice();return d.splice(l,0,s),d}function V(e,t,n,r){let i=t.filter(t=>M(e,t)&&!R(e,t.id)),a=i.findIndex(e=>e.id===n);if(a<0)return t;let o=a+r;if(o<0||o>=i.length)return t;let s=i[o];return B(e,t,{id:n,anchorId:s.id,after:r>0})}function H({kind:e,layout:t,setLayout:n,onClose:r}){let[i,a]=(0,g.useState)(()=>t.map(e=>({...e}))),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=(0,g.useRef)(null),d=i.filter(t=>M(e,t)),f=i.filter(t=>N(e,t)),p=d.filter(t=>!R(e,t.id)),m=()=>{let t=u.current;return t&&!R(e,t.id)?t:null},h=(t,n)=>{R(e,n.id)||(u.current={id:n.id,onBar:M(e,n)},l(n.id),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,n.id)))},v=()=>{u.current=null,l(null),s(null)},y=(t,n)=>{a(r=>B(e,r,{...n,id:t.id,visible:t.onBar===!1||n.visible}))},b=e=>{let t=e.clientY;for(let n of e.currentTarget.querySelectorAll(`[data-row-id]`)){let e=n.getBoundingClientRect();if(t<e.top)return{anchorId:n.dataset.rowId,after:!1};if(t<=e.bottom)return{anchorId:n.dataset.rowId,after:t>e.top+e.height/2}}return{anchorId:null,after:!1}},x=e=>{let t=m();if(!t)return;e.preventDefault();let n=b(e);s(n.anchorId?n.anchorId===t.id?null:`row:${n.anchorId}:${n.after?`after`:`before`}`:`zone:bar:end`)},S=e=>{e.preventDefault();let t=b(e),n=m();v(),n&&y(n,{anchorId:t.anchorId,after:t.after,visible:!0})},C=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e&&e.startsWith(`zone:`)?null:e)},w=t=>{let n=m();n&&!A(e,n.id).noHide&&(t.preventDefault(),s(`menu`))},T=t=>{t.preventDefault();let n=m();v(),n&&!A(e,n.id).noHide&&a(e=>z(e,n.id,{visible:!1}))},E=e=>{e.currentTarget.contains(e.relatedTarget)||s(e=>e===`menu`?null:e)},D=e=>{let t=e.currentTarget.getBoundingClientRect();return(e.clientX-t.left)/(t.width||1)>.5},O=(e,t)=>{let n=m();n&&n.id!==e.id&&(t.preventDefault(),s(`chip:${e.id}:${D(t)?`after`:`before`}`))},k=(e,t)=>{let n=D(t);t.preventDefault();let r=m();v(),r&&y(r,{anchorId:e.id,after:n,visible:!0})},j=t=>{A(e,t).noHide||a(n=>{let r=n.find(e=>e.id===t);return z(n,t,{visible:!(r&&M(e,r))})})},P=(t,n)=>a(r=>V(e,r,t.id,n)),I=(e,t)=>{t.altKey&&(t.key===`ArrowUp`?(t.preventDefault(),P(e,-1)):t.key===`ArrowDown`&&(t.preventDefault(),P(e,1)))},L=()=>{n(i),r()},H=()=>a(F(e)),U=(t,n)=>{let r=o===`row:${t.id}:before`?` drop-before`:o===`row:${t.id}:after`?` drop-after`:``;return[`tlp-row`,n?``:`off`,R(e,t.id)?`lock`:``,c===t.id?`dragging`:``,r].filter(Boolean).join(` `)};return(0,_.jsxs)(`div`,{className:`tlp-panel`,role:`dialog`,"aria-label":`自定义工具栏`,children:[(0,_.jsxs)(`div`,{className:`tlp-head`,children:[(0,_.jsx)(`b`,{children:`自定义工具栏`}),(0,_.jsx)(`span`,{className:`tlp-head-sub`,children:`拖拽排序;关显隐 → 收入「更多」`})]}),(0,_.jsxs)(`div`,{className:`tlp-body`,children:[(0,_.jsxs)(`div`,{className:`tlp-section tlp-span`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`预览(可直接拖动这里的按钮排序)`}),(0,_.jsx)(`div`,{className:`tlp-preview`,role:`list`,"data-testid":`tlp-preview`,children:d.map(t=>{let n=o===`chip:${t.id}:before`?` drop-before`:o===`chip:${t.id}:after`?` drop-after`:``;return(0,_.jsx)(`span`,{className:[`tlp-chip`,A(e,t.id).section===`primary`?`primary`:``,c===t.id?`dragging`:``,n].filter(Boolean).join(` `),draggable:!R(e,t.id),role:`listitem`,onDragStart:e=>h(e,t),onDragEnd:v,onDragOver:e=>O(t,e),onDrop:e=>k(t,e),children:A(e,t.id).label||t.id},t.id)})})]}),(0,_.jsxs)(`div`,{className:`tlp-section`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`工具栏 · 拖进来即排序(行上/下半 = 前/后)`}),(0,_.jsxs)(`div`,{className:`tlp-list`+(o===`zone:bar:end`?` drop-on`:``),role:`list`,onDragOver:x,onDragLeave:C,onDrop:S,children:[p.length===0&&d.every(t=>R(e,t.id))?(0,_.jsx)(`div`,{className:`tlp-empty`,children:`空 —— 把「更多」里的项拖到这里`}):null,d.map(t=>{let n=A(e,t.id),r=p.findIndex(e=>e.id===t.id);return(0,_.jsxs)(`div`,{className:U(t,!0),draggable:!R(e,t.id),"data-row-id":t.id,tabIndex:R(e,t.id)?void 0:0,role:`listitem`,"aria-label":`${n.label||t.id}:拖动排序,Alt+上下换位`,onKeyDown:e=>I(t,e),onDragStart:e=>h(e,t),onDragEnd:v,children:[(0,_.jsx)(`span`,{className:`tlp-hnd`,title:R(e,t.id)?`锁定`:`拖动排序`,children:R(e,t.id)?`·`:`⋮⋮`}),(0,_.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:!!n.noHide,onChange:()=>j(t.id),title:n.noHide?`不可隐藏`:`收入「更多」`}),(0,_.jsxs)(`span`,{className:`tlp-nm`,children:[n.label||t.id,n.noHide?(0,_.jsx)(`span`,{className:`tlp-sub`,children:`固定显示`}):null]}),R(e,t.id)?null:(0,_.jsxs)(`span`,{className:`tlp-acts`,children:[(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<=0,title:`上移`,onClick:()=>P(t,-1),children:`↑`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:r<0||r>=p.length-1,title:`下移`,onClick:()=>P(t,1),children:`↓`})]})]},t.id)})]})]}),(0,_.jsxs)(`div`,{className:`tlp-section`,children:[(0,_.jsx)(`div`,{className:`tlp-section-label`,children:`更多菜单(拖到上方 = 显示到工具栏;拖回这里 = 收入更多)`}),(0,_.jsxs)(`div`,{className:`tlp-list tlp-menu`+(o===`menu`?` dropping`:``),role:`list`,onDragOver:w,onDragLeave:E,onDrop:T,children:[f.map(t=>{let n=A(e,t.id);return(0,_.jsxs)(`div`,{className:U(t,!1),draggable:!0,role:`listitem`,onDragStart:e=>h(e,t),onDragEnd:v,children:[(0,_.jsx)(`span`,{className:`tlp-hnd`,title:`拖到上方工具栏 = 显示`,children:`⋮⋮`}),(0,_.jsx)(`input`,{type:`checkbox`,checked:!1,onChange:()=>j(t.id),title:`显示到工具栏`}),(0,_.jsx)(`span`,{className:`tlp-nm`,children:n.label||t.id})]},t.id)}),(0,_.jsx)(`div`,{className:`tlp-drop-hint`,role:`presentation`,children:o===`menu`?`松手 = 收入「更多」`:f.length?`把项拖到上方工具栏区域 = 显示到工具栏`:`工具栏上的按钮拖到这里即可收入「更多」`})]})]})]}),(0,_.jsxs)(`div`,{className:`tlp-foot`,children:[(0,_.jsx)(`span`,{className:`tlp-equiv`,children:`保存到本机 localStorage(每种工具区各存一份)`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:H,children:`恢复默认`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:r,children:`取消`}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:L,children:`保存`})]})]})}var U=`task`,W=[{id:`edit`,label:`编辑`},{id:`task`,label:`任务`},{id:`view`,label:`查看`}];function G(){let[e,t]=(0,g.useState)(!1),[n,r]=(0,g.useState)({x:0,y:0}),i=(0,g.useRef)(null),a=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!e)return;let n=e=>{i.current?.contains(e.target)||a.current?.contains(e.target)||t(!1)};return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),{open:e,setOpen:t,pos:n,setPos:r,ref:i,menuRef:a}}function K({menu:e,className:t=``,style:n,children:r}){return e.open?(0,x.createPortal)((0,_.jsx)(`div`,{className:`mdw-fmt-menu${t?` ${t}`:``}`,role:`menu`,ref:e.menuRef,style:{position:`fixed`,...e.pos,...n},children:r}),document.body):null}function q(e,t,n=`left`){let r=t.currentTarget.getBoundingClientRect(),i=r.bottom+4;e.setPos(n===`left`?{left:r.left,top:i}:{left:`auto`,right:Math.max(8,window.innerWidth-r.right),top:i}),e.setOpen(e=>!e)}function J({mode:e,onMode:t,showMark:n,submitLabel:r,onNew:i,onSubmit:a,onChain:o,onPreview:s,onImg:c,onAtt:l,onImport:u,onClone:d,onFork:f,onComplete:p,onCancelTask:m,onMark:h,onDraft:v,onDelete:y,onOverview:b,onProg:S,onSource:C,onShortcuts:w,goalBadge:T,goalMenu:E}){let D=G(),{layout:O,setLayout:k}=L(U),[j,P]=(0,g.useState)(!1);(0,g.useEffect)(()=>{D.setOpen(!1)},[e]);let F={new:i&&{label:`新任务`,run:i},submit:{label:r||`提交`,run:a,primary:!0},mode:t&&{label:e===`edit`?`返回实时预览`:`源码模式`,hint:e===`edit`?`当前`:``,run:()=>t(e===`edit`?`split`:`edit`)},img:c&&{label:`插入图片`,run:c},att:l&&{label:`添加附件`,run:l},import:u&&e!==`split`&&{label:`导入`,run:u},draft:v&&e!==`split`&&{label:`存草稿`,run:v},chain:o&&{label:`任务链`,run:o},clone:d&&{label:`克隆任务`,run:d},fork:f&&{label:`Fork 任务`,run:f},complete:p&&{label:`标为完成`,run:p},"cancel-task":m&&{label:`取消任务`,run:m,danger:!0},mark:n&&h&&{label:`评论`,run:h},delete:y&&{label:`删除`,run:y,danger:!0},preview:s&&{label:`预览提示词`,run:s},overview:b&&{label:`总览`,run:b},prog:S&&{label:`进程`,run:S},source:C&&{label:`原文`,run:C},shortcuts:w&&{label:`快捷键`,run:w}},I=e=>e===`more`||!!F[e],R=O.filter(e=>M(U,e)&&I(e.id)),z=O.filter(e=>N(U,e)&&I(e.id)),B=e=>{F[e]?.run?.(),D.setOpen(!1)},V=e=>{if(e===`more`)return(0,_.jsx)(`div`,{className:`mdw-actions-more`,ref:D.ref,children:(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm${D.open?` on`:``}`,title:`更多操作`,"aria-expanded":D.open,"aria-haspopup":`menu`,onClick:e=>q(D,e,`right`),children:`更多`})},`more`);let t=F[e];return t?(0,_.jsx)(`button`,{type:`button`,className:t.primary?`btn sm primary`:`btn ghost sm`,onClick:()=>B(e),children:t.label},e):null},J=W.map(e=>({...e,items:z.filter(t=>A(U,t.id).menuGroup===e.id)})).filter(e=>e.items.length),Y=z.filter(e=>!A(U,e.id).menuGroup);return(0,_.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,_.jsx)(`div`,{className:`mdw-toolbar-left`,children:T&&(0,_.jsx)(`button`,{type:`button`,className:`mdw-goal-badge`,title:T.title,"aria-haspopup":`menu`,"aria-expanded":D.open,onClick:e=>q(D,e,`right`),children:T.label})}),(0,_.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`任务操作`,children:[R.map(e=>V(e.id)),(0,_.jsxs)(K,{menu:D,className:`mdw-act-menu`,children:[E,E&&(0,_.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),J.map(e=>(0,_.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,_.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=F[e.id],n=t?.danger||A(U,e.id).danger;return(0,_.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>B(e.id),children:[t?.label||A(U,e.id).label||e.id,t?.hint?(0,_.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),Y.map(e=>{let t=F[e.id];return(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||A(U,e.id).danger?` danger`:``),onClick:()=>B(e.id),children:t?.label||A(U,e.id).label||e.id},e.id)}),(0,_.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{D.setOpen(!1),P(!0)},children:`自定义工具栏…`})]})]}),j&&(0,x.createPortal)((0,_.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>P(!1),children:(0,_.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,_.jsx)(H,{kind:U,layout:O,setLayout:k,onClose:()=>P(!1)})})}),document.body)]})}export{H as a,A as c,G as i,M as l,J as n,L as o,q as r,N as s,K as t,y as u};
@@ -12,7 +12,7 @@
12
12
  <!-- .ico 兜底:浏览器不认上面的 <link> 时会自己请求 /favicon.ico -->
13
13
  <link rel="icon" type="image/x-icon" href="/favicon.ico">
14
14
  <link rel="apple-touch-icon" sizes="512x512" href="/logo-rounded.png">
15
- <script type="module" crossorigin src="/assets/index-BrAIkzFc.js"></script>
15
+ <script type="module" crossorigin src="/assets/index-DNB8tgNi.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="/assets/task-status-BnymQMTw.js">
17
17
  <link rel="modulepreload" crossorigin href="/assets/workspace-C_5X2gIr.js">
18
18
  <link rel="modulepreload" crossorigin href="/assets/app-context-D7HAx67n.js">
@@ -21,7 +21,7 @@
21
21
  <link rel="modulepreload" crossorigin href="/assets/board-view-CZKZsyk-.js">
22
22
  <link rel="modulepreload" crossorigin href="/assets/model-DzdWfp14.js">
23
23
  <link rel="stylesheet" crossorigin href="/assets/task-status-BZrdOH46.css">
24
- <link rel="stylesheet" crossorigin href="/assets/index-CZzMw1zg.css">
24
+ <link rel="stylesheet" crossorigin href="/assets/index-DGvBoOdp.css">
25
25
  </head>
26
26
  <body>
27
27
  <div id="root"></div>
@@ -1 +0,0 @@
1
- import{g as e,h as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./task-status-BnymQMTw.js";import{r as c,v as l,w as u}from"./workspace-C_5X2gIr.js";import{n as d}from"./app-context-D7HAx67n.js";import{_ as f,a as p,i as m,n as h,p as g,r as _,t as v,u as y,v as b,y as x}from"./md-history-DB5forf2.js";import{a as S,i as C}from"./upload-BIMbGcCB.js";import{a as w,r as ee}from"./md-parse-awNLHAzO.js";import{t as T}from"./route-crumb-C8JzPIax.js";import{a as E,c as D,i as O,l as k,o as A,r as j,s as M,t as N,u as te}from"./tool-bar-DGCwnUcn.js";var P=s(e(),1),F=u(),I=t(),L=`doc`,R=[{id:`edit`,label:`编辑`},{id:`doc`,label:`文档`},{id:`view`,label:`查看`}];function ne({crumb:e=null,title:t,pathLabel:n=``,dirty:r=!1,writable:i=!1,onSave:a=null,onSaveLabel:o=`保存`,menuGroups:s=[],saving:c=!1,external:l=!1,afterTitle:u=null}){let d=O(),{layout:f,setLayout:p}=A(L),[m,h]=(0,P.useState)(!1),g={};for(let e of s||[])for(let t of e?.items||[])t&&t.id&&(g[t.id]=t);g.save=a&&{id:`save`,label:c?`保存中…`:o,run:a,primary:!0,disabled:c||!r};let _=e=>e===`more`||!!g[e],v=f.filter(e=>k(L,e)&&_(e.id)),y=f.filter(e=>M(L,e)&&_(e.id)),b=e=>{g[e]?.run?.(),d.setOpen(!1)},x=e=>{if(e===`more`)return(0,I.jsx)(`div`,{className:`docp-more`,ref:d.ref,children:(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm${d.open?` on`:``}`,title:`更多操作`,"aria-haspopup":`menu`,"aria-expanded":d.open,onClick:e=>j(d,e,`right`),children:`更多`})},`more`);let t=g[e];return t?(0,I.jsx)(`button`,{type:`button`,className:t.primary||e===`save`?`btn sm primary docp-save`:`btn ghost sm`,disabled:!!t.disabled,onClick:()=>b(e),children:t.label||D(L,e).label||e},e):null},S=R.map(e=>({...e,items:y.filter(t=>D(L,t.id).menuGroup===e.id)})).filter(e=>e.items.length),C=y.filter(e=>!D(L,e.id).menuGroup);return i?(0,I.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,I.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,I.jsx)(`span`,{className:`grow`}),u,(0,I.jsxs)(`div`,{className:`docp-actions`,children:[v.map(e=>x(e.id)),(0,I.jsxs)(N,{menu:d,className:`mdw-act-menu`,children:[S.map(e=>(0,I.jsxs)(`div`,{className:`mdw-fmt-menu-group`,role:`group`,"aria-label":e.label,children:[(0,I.jsx)(`div`,{className:`mdw-fmt-menu-cap`,children:e.label}),e.items.map(e=>{let t=g[e.id],n=t?.danger||D(L,e.id).danger;return(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(n?` danger`:``),onClick:()=>b(e.id),children:[t?.label||D(L,e.id).label||e.id,t?.hint?(0,I.jsx)(`span`,{className:`hint`,children:t.hint}):null]},e.id)})]},e.id)),C.map(e=>{let t=g[e.id];return(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(t?.danger||D(L,e.id).danger?` danger`:``),onClick:()=>b(e.id),children:t?.label||D(L,e.id).label||e.id},e.id)}),(0,I.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`,onClick:()=>{d.setOpen(!1),h(!0)},children:`自定义工具栏…`})]})]})]}),m&&(0,F.createPortal)((0,I.jsx)(`div`,{className:`ta-panel-mask`,onClick:()=>h(!1),children:(0,I.jsx)(`div`,{className:`ta-panel-wrap`,onClick:e=>e.stopPropagation(),children:(0,I.jsx)(E,{kind:L,layout:f,setLayout:p,onClose:()=>h(!1)})})}),document.body)]}):(0,I.jsxs)(`div`,{className:`mdw-top docp-top`,children:[e,(0,I.jsxs)(`div`,{className:`mdw-head`,children:[(0,I.jsx)(`div`,{className:`mdw-title`,children:t||`文档`}),(0,I.jsxs)(`div`,{className:`mdw-path`,children:[n,r?` · 未保存`:``,l?` · 外部`:``]}),(0,I.jsx)(`span`,{className:`grow`}),u,(0,I.jsx)(`div`,{className:`docp-actions`,children:(0,I.jsx)(`span`,{className:`docp-tag ext`,children:`只读`})})]})]})}function z(e,t,n){return{id:e,label:t,items:n.filter(Boolean)}}var B=o({default:()=>H,useWikiNav:()=>V});function V(e){let t=d()||{},n=a(),i=e||t.model,o=(0,P.useRef)(null),s=(0,P.useCallback)(async()=>{if(!o.current)try{o.current=(await r(`/api/docs/index`)).index||[]}catch{o.current=[]}return o.current},[]),l=(0,P.useCallback)(async(e,t,n={})=>{let r=(t||await s()).find(t=>t.docId===e);c(i,{component:`doc`,name:r?r.name:e,config:{docId:e,...n.repoKey?{repoKey:n.repoKey}:{},...n.boardKey?{boardKey:n.boardKey,boardName:n.boardName||``}:{}},location:`center`})},[i,s]),u=(0,P.useCallback)(async e=>{let t=await s(),r=x(e,t);if(r&&r.docId)return l(r.docId,t);if(r&&r.candidates)return n(`「${e}」同名文档多份:${r.candidates.join(`、`)}`);n(`未找到「${e}」——可用 nx-kv docs add <rel> 创建`)},[s,l,n]);return{nav:u,onClick:(0,P.useCallback)(e=>{let t=e.target.closest(`[data-wl]`);t&&(e.preventDefault(),u(t.getAttribute(`data-wl`)))},[u]),ensureIndex:s,openByDocId:l}}function H({docId:e,repoKey:t,boardKey:i,boardName:o,model:s,tabId:u}){let d=a(),{dialog:x,node:E}=n(),D=(0,P.useRef)(new Map),O=(0,P.useRef)(null),k=(0,P.useRef)(null),{onClick:A,openByDocId:j}=V(s),M=t?`repo`:i?`board`:``,N=t||i||``,F=(0,P.useMemo)(()=>t?{repoKey:t}:i?{boardKey:i,boardName:o||``}:{},[t,i,o]),[L,R]=(0,P.useState)(null),[B,H]=(0,P.useState)(``),[re,W]=(0,P.useState)(!1),[G,K]=(0,P.useState)(`split`),[q,J]=(0,P.useState)([]),[ie,Y]=(0,P.useState)(null),X=(0,P.useRef)(null);(0,P.useEffect)(()=>{X.current=L},[L]);let Z=(0,P.useCallback)(async()=>{H(``);try{let t=await r(`/api/docs/item?ref=`+encodeURIComponent(e||``));R(t),W(!1)}catch(e){H(String(e.message||e)),R(null)}},[e]);(0,P.useEffect)(()=>{R(null),Z()},[Z]);let oe=(0,P.useCallback)(()=>{if(!N){J([]);return}if(M===`repo`){r(`/api/repos/docs?id=`+encodeURIComponent(N)).then(t=>{let n=[],r=(e,t)=>{if(!e)return;let r=e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``;r&&n.push({docId:r,label:e.rel||e.path||(t?`主篇`:`补充`),note:e.note||``,main:t})};r(t.main||{rel:`repo/${N}.md`},!0);for(let e of t.links||[])r(e,!1);e&&!n.some(t=>t.docId===e)&&n.push({docId:e,label:`当前`,note:``,main:!0}),J(n)}).catch(()=>J(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]));return}r(`/api/boards`).then(t=>{let n=(t&&t.boards||(Array.isArray(t)?t:[])).find(e=>e.id===N||e.key===N),r=[];e&&r.push({docId:e,label:`当前`,note:``,main:!0});for(let e of n&&n.docLinks||[]){let t=e.rel?`rel:${e.rel}`:e.path?`path:${e.path}`:``;t&&!r.some(e=>e.docId===t)&&r.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,main:!1})}J(r)}).catch(()=>J(e?[{docId:e,label:`当前`,note:``,main:!0}]:[]))},[N,M,e]);(0,P.useEffect)(()=>{oe()},[oe]);let[se,ce]=(0,P.useState)(null);(0,P.useEffect)(()=>{r(`/api/docs/index`).then(e=>{let t=new Set;for(let n of e.index||[])t.add(n.name),n.rel&&t.add(String(n.rel).toLowerCase()),n.path&&t.add(String(n.path).replace(/\\/g,`/`).toLowerCase());ce(t)}).catch(()=>{})},[]);let Q=!!(L&&L.writable),le=(0,P.useMemo)(()=>L?b(L.body,[],Q?se:null):``,[L,se,Q]),ue=(0,P.useMemo)(()=>L?f(L.body):[],[L]);(0,P.useEffect)(()=>{let e=k.current;if(!e)return;let t=()=>e.querySelector(`.mdw-preview, .mdw-lp`)||null;Y(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Y(t())):null;return n&&n.observe(e,{childList:!0,subtree:!0}),()=>{n&&n.disconnect()}},[L,G,le]);let $=e=>e().catch(e=>d(String(e.message||e))),de=(0,P.useCallback)(e=>j(e,null,F),[j,F]),fe=(0,P.useCallback)(()=>{let e=s;e&&N&&c(e,{component:`refs`,name:`文档列表`,config:t?{repoKey:t}:{boardKey:i,boardName:o||``},location:`right`})},[s,N,t,i,o]),pe=()=>{N&&$(async()=>{let t=await x({title:`补充介绍文档`,input:!0,placeholder:`文档名(如 architecture / api-notes)`});if(t===null)return;let n=ee(String(t).trim()||`note`).replace(/\.md$/i,``),i=`${String(e||``).startsWith(`rel:`)?U(e):M===`repo`?`repo/${N}`:`board/${o||N}`}/reference/${n}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:i,body:`# ${String(t).trim()||n}\n\n(待补)\n`}});try{M===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:N,rel:i}}):await r(`/api/docs/link`,{method:`POST`,body:{board:N,doc:i}})}catch{}d(`已补充:${i}`),oe(),j(`rel:`+i,null,F)})},me=()=>$(async()=>{if(!L||!Q)return;let t=await r(`/api/docs/item`,{method:`PATCH`,body:{ref:e,body:L.body}});R(e=>({...e,body:L.body,summary:t.summary})),W(!1),v(D.current,e),d(t.summary?`已保存,摘要已回写`:`已保存`)}),he=(t,n=`op`)=>{L&&(h(D.current,e,{body:L.body},n),W(!0),R(e=>({...e,body:t,title:w(t,e.title)})))},ge=(t,n=`typing`)=>{if(!L)return;h(D.current,e,{body:L.body},n),W(!0);let r=/^#\s+/m.test(L.body)?L.body.replace(/^#\s+.+$/m,`# ${t||`未命名文档`}`):`# ${t||`未命名文档`}\n\n${L.body}`;R(e=>({...e,body:r,title:t}))},_e=()=>{if(!L)return;let t=m(D.current,e,{body:L.body});t&&(R(e=>({...e,body:t.body,title:w(t.body,e.title)})),W(!0),requestAnimationFrame(()=>O.current?.caretFromDiff?.(L.body,t.body)))},ve=()=>{if(!L)return;let t=_(D.current,e,{body:L.body});t&&(R(e=>({...e,body:t.body,title:w(t.body,e.title)})),W(!0),requestAnimationFrame(()=>O.current?.caretFromDiff?.(L.body,t.body)))},ye=async(t,n={})=>{if(!Q)return;let r=[...t||[]];if(r.length)try{let t=await S(r,{local:!0,onProgress:(e,t,n)=>d(`正在上传 ${e}/${t}:${n.name}`)}),i=C(t);if(!i)return;let a=X.current||L;if(!a)return;let o=g(a.body,i,n);h(D.current,e,{body:a.body}),W(!0),R(e=>e&&{...e,body:o.body,title:w(o.body,e.title)}),d(`已插入 ${t.length} 个附件`)}catch(e){d(`附件上传失败:${String(e.message||e)}`)}},be=()=>{L&&L.rel&&$(async()=>{let t=await x({title:`重命名文档`,input:!0,value:L.rel,placeholder:`新路径(相对 docs 根,以 .md 结尾)`});if(t===null)return;let n=String(t).trim();if(n&&n!==L.rel){if(!/\.md$/i.test(n))return d(`文档路径必须以 .md 结尾`);try{await r(`/api/docs/item`,{method:`POST`,body:{rel:n,body:L.body}})}catch(e){d(`重命名失败:${String(e.message||e)}`);return}await r(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),v(D.current,e),d(`已重命名为:${n}`),j(`rel:`+n,null,F)}})},xe=()=>{L&&$(async()=>{await x({title:`删除文档「${L.title||L.rel||e}」`,message:`磁盘上的 ${L.rel||e} 会被一并删除,不可恢复。`,danger:!0,okText:`删除`})&&(await r(`/api/docs/item`,{method:`DELETE`,body:{ref:e}}),d(`已删除:${L.rel||e}`),s&&u&&s.doAction(l.deleteTab(u)))})},Se=()=>$(async()=>{let t=String(e||``).startsWith(`rel:`)?e.slice(4):String(e||``).startsWith(`path:`)?``:String(e||``);if(!t)return;let n=t.replace(/\.md$/i,``).split(`/`).pop()||`未命名文档`;await r(`/api/docs/item`,{method:`POST`,body:{rel:t,body:`# ${n}\n\n(待补)\n`}}),d(`已创建:${t}`),await Z()});if(L&&L.dir)return(0,I.jsxs)(`div`,{className:`mdw docp`,children:[(0,I.jsxs)(`div`,{className:`docp-head`,children:[(0,I.jsx)(`span`,{className:`docp-path mono`,children:L.path}),(0,I.jsx)(`span`,{className:`docp-tag ext`,children:`外部目录 · 只读`})]}),(0,I.jsxs)(`div`,{className:`docp-files`,children:[L.files.map(e=>(0,I.jsx)(`button`,{className:`docp-file`,onClick:()=>j(`path:`+e,null),children:e},e)),!L.files.length&&(0,I.jsx)(`div`,{className:`muted pad`,children:`(目录里还没有 .md 文档)`})]})]});if(B)return(0,I.jsx)(`div`,{className:`mdw docp`,children:(0,I.jsxs)(`div`,{className:`pad stack`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:`文档打开失败`})}),(0,I.jsx)(`div`,{className:`hint`,children:B})]})});if(!L)return(0,I.jsx)(`div`,{className:`mdw`,children:(0,I.jsx)(`div`,{className:`pad muted`,children:`载入中…`})});if(L.missing){let t=String(e||``).startsWith(`rel:`)||!String(e||``).startsWith(`path:`);return(0,I.jsxs)(`div`,{className:`mdw docp`,children:[(0,I.jsx)(`div`,{className:`docp-head`,children:(0,I.jsx)(`span`,{className:`docp-path mono`,children:L.rel||L.path||e})}),(0,I.jsxs)(`div`,{className:`pad stack`,children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:`文档还没有落盘`})}),(0,I.jsx)(`div`,{className:`hint`,children:`描述内容的权威是磁盘上的 .md 文件——对应的字符串字段会在读取时播种,也可以直接创建骨架。`}),t&&(0,I.jsx)(`div`,{children:(0,I.jsx)(`button`,{className:`btn sm`,onClick:Se,children:`创建骨架`})})]})]})}let Ce=Q?G:`read`;return(0,I.jsxs)(`div`,{className:`mdw docp`,"data-mode":Ce,onClick:A,ref:k,children:[(0,I.jsxs)(`div`,{className:`mdw-main`,children:[(0,I.jsx)(ne,{crumb:(0,I.jsx)(T,{}),title:L.title||L.rel||L.path||`文档`,pathLabel:L.rel||L.path||``,dirty:re,writable:Q,external:!!L.external,menuGroups:[z(`edit`,`编辑`,[{id:`mode`,label:G===`edit`?`返回实时预览`:`源码模式`,hint:G===`edit`?`当前`:``,run:()=>K(G===`edit`?`split`:`edit`)}]),z(`doc`,`文档`,[{id:`rename`,label:`重命名`,run:be},{id:`delete`,label:`删除`,run:xe,danger:!0}]),z(`view`,`查看`,[N&&{id:`list`,label:`文字列表`,hint:`右侧边栏`,run:fe}])],onSave:me}),L.summary&&Q&&(0,I.jsxs)(`div`,{className:`docp-summary`,children:[`摘要(回写 desc):`,L.summary]}),(0,I.jsx)(p,{mode:Ce,title:L.title,body:L.body,previewHtml:le,onTitle:Q?ge:null,onBody:Q?he:null,onFiles:Q?ye:null,attachments:[],docKey:e,editorApiRef:O,onSave:Q?me:null,onUndo:Q?_e:null,onRedo:Q?ve:null}),(0,I.jsx)(te,{host:`ref`,refId:e,allow:{file:!0,url:!0,task:!1,ref:!0},disabled:!Q,disabledText:`只读文档不能添加附件。`,onOpenDoc:e=>{let t=y(e);t&&j(t,null,F)}}),(0,I.jsx)(`div`,{className:`docp-hint`,children:`双链 [[]] 点击跳转 · Ctrl+S 保存 · 文档即磁盘文件(~/.nx-kv/docs/)`})]}),(0,I.jsx)(ae,{headings:ue,scrollRoot:ie,links:q,activeDocId:e,onOpenDoc:N?de:null,onAddRef:N?pe:null}),E]})}function U(e){let t=String(e||``).startsWith(`rel:`)?String(e).slice(4):``;return t?/\/index\.md$/i.test(t)?t.replace(/\/index\.md$/i,``):/\.md$/i.test(t)?t.replace(/\.md$/i,``):t.replace(/\/+$/,``):``}function re(e,t){return e?e.doc&&e.doc.path?`path:`+e.doc.path:e.doc&&e.doc.rel?`rel:`+e.doc.rel:e.docPath?`path:`+e.docPath:e.docRel?`rel:`+e.docRel:t===`repo`&&e.key?`rel:repo/`+e.key+`.md`:``:``}function W(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function G({kind:e,owner:t,model:n}){let{openByDocId:i}=V(n),a=e===`board`?`组介绍`:`项目介绍`,o=e===`board`?t&&(t.id||t.key):t&&t.key,s=t&&t.name,c=(0,P.useMemo)(()=>re(t,e),[t,e]),[l,u]=(0,P.useState)([]),[d,f]=(0,P.useState)(``),[p,m]=(0,P.useState)(0),h=(0,P.useCallback)(()=>m(e=>e+1),[]);(0,P.useEffect)(()=>{let n=!0;if(!o){u([]);return}if(e===`repo`)r(`/api/repos/docs?id=`+encodeURIComponent(o)).then(e=>{if(!n)return;let t=[],r=W(e.main);f(r||c),r&&t.push({docId:r,label:e.main.rel||e.main.path||`主篇`,note:e.main.note||``,tag:e.main.tag||``,main:!0,ref:e.main.ref||``});for(let n of e.extras||[]){let e=W(n);e&&t.push({docId:e,label:n.name||n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}for(let n of e.links||[]){let e=W(n);e&&t.push({docId:e,label:n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}u(t)}).catch(()=>{n&&(u([]),f(c))});else{let e=()=>{let e=[];c&&e.push({docId:c,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let n of t?.docLinks||[]){let t=W(n);t&&e.push({docId:t,label:n.rel||n.path||`补充`,note:n.note||``,tag:n.tag||``,main:!1,ref:n.ref||``})}return e};r(`/api/boards/`+encodeURIComponent(String(o))).then(t=>{if(!n)return;let r=Array.isArray(t&&t.docLinks)?t.docLinks:null;if(!r){u(e()),f(c);return}let i=[],a=W(t&&t.introMain)||c;f(a),a&&i.push({docId:a,label:`主篇`,note:``,tag:``,main:!0,ref:``});for(let e of t&&t.introExtras||[]){let t=W(e);t&&i.push({docId:t,label:e.name||e.rel||e.path||`补充`,note:e.note||``,tag:e.tag||``,main:!1,ref:e.ref||``})}for(let e of r){let t=W(e);t&&i.push({docId:t,label:e.rel||e.path||`补充`,note:e.note||``,tag:e.tag||``,main:!1,ref:e.ref||``})}u(i)}).catch(()=>{n&&(u(e()),f(c))})}return()=>{n=!1}},[e,o,t,c,p]);let g=(0,P.useMemo)(()=>e===`repo`&&o?{repoKey:o}:e===`board`&&o?{boardKey:o,boardName:s||``}:{},[e,o,s]);return{kind:e,label:a,ownerKey:o,docRef:c,mainDocId:d,links:l,openMain:(0,P.useCallback)(()=>{let e=d||c;e&&i(e,null,g)},[d,c,i,g]),openDoc:(0,P.useCallback)(e=>i(e,null,g),[i,g]),addRef:(0,P.useCallback)(async(t,n)=>{if(!o||!c.startsWith(`rel:`))return n&&n(`当前简介无法补充(需要自有树路径)`),null;let a=await t({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(a===null)return null;let l=typeof a==`string`?a:a&&a.value||``,u=typeof a==`object`&&a&&a.tag||``,d=ee(String(l).trim()||`note`).replace(/\.md$/i,``),f=`${U(c)||(e===`repo`?`repo/${o}`:`board/${s||o}`)}/reference/${d}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:f,body:`# ${String(l).trim()||d}\n\n(待补)\n`}});try{e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:o,rel:f,tag:u||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:o,doc:f,tag:u||void 0}})}catch{}return n&&n(`已补充:${f}${u?` [${u}]`:``}`),h(),i(`rel:`+f,null,g),f},[o,c,e,s,i,g,h]),setLinkTag:(0,P.useCallback)(async(t,n,i)=>{if(!o)throw Error(`缺少归属`);let a=String(t||``).startsWith(`path:`)?{path:String(t).slice(5)}:{rel:String(t||``).startsWith(`rel:`)?String(t).slice(4):String(t||``)},s=i&&i.note||``;e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:o,...a,note:s||void 0,tag:n||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:o,doc:a.path||a.rel,note:s||void 0,tag:n||void 0}}),h()},[o,e,h]),reload:h,canEdit:!!c}}function K(e){return e?e.rel?`rel:`+e.rel:e.path?`path:`+e.path:``:``}function q(e){let t=e.rel||e.path||``;return String(t).replace(/[\\/]+$/,``).split(/[\\/]/).pop()||t||`未命名`}function J(e,t,n){let r=[],i=e&&(e.main||e.introMain);i&&r.push({id:K(i),kind:`main`,label:`主篇`,sub:i.rel||i.path||``,tag:``,note:``,docId:K(i),removable:n===`repo`&&!!(t&&t.doc),removeTip:`摘除主篇自定义绑定(回退约定路径,文档不删)`,taggable:!1});for(let t of e&&(e.extras||e.introExtras)||[]){let e=K(t);e&&r.push({id:e,kind:`extra`,label:q(t),sub:t.rel||t.path||``,tag:``,note:``,docId:e,removable:!1,taggable:String(e).startsWith(`rel:`)})}(e&&(e.links||e.docLinks)||[]).forEach((e,t)=>{let i=K(e);i&&r.push({id:i,kind:`link`,label:q(e),sub:e.rel||e.path||``,tag:e.tag||``,note:e.note||``,docId:i,removeIndex:n===`repo`?t+2:t+1,removable:!0,taggable:!0})});for(let e of n===`repo`&&t&&t.boards||[]){let t=e.noteDocPath||``,n=e.noteDocRel||``,i=t?`path:`+t:n?`rel:`+n:``;i&&r.push({id:i,kind:`scoped`,label:`${e.name} · 组内描述`,sub:t||n,tag:``,note:e.note||``,docId:i,removable:!1,taggable:!1})}return r.filter(e=>e.docId)}var ie={main:`● `,scoped:`◇ `,extra:`○ `,link:`○ `};function Y({kind:e,owner:t,model:o,onClose:s,onChanged:l}){let u=a(),{dialog:f,node:p}=n(),m=d()||{},h=o||m.model,g=G({kind:e,owner:t,model:h}),_=g.ownerKey,v=t&&t.name,[y,b]=(0,P.useState)([]),[x,S]=(0,P.useState)(!0),[C,w]=(0,P.useState)(``),T=(0,P.useCallback)(async()=>{if(!_){b([]),S(!1);return}S(!0);try{let n=e===`repo`?await r(`/api/repos/docs?id=`+encodeURIComponent(_)):await r(`/api/boards/`+encodeURIComponent(String(_)));b(J(n,t,e)),w(``)}catch(e){b([]),w(String(e.message||e))}finally{S(!1)}},[e,_,t]);(0,P.useEffect)(()=>{T()},[T]);let E=t=>{if(!t)return;let n=h;if(!n){u(`工作区不可用,无法打开文档`);return}c(n,{component:`doc`,name:t.label||t.sub||t.docId,config:{docId:t.docId,...e===`repo`?{repoKey:_}:{boardKey:_,boardName:v||``}},location:`center`}),s()},D=e=>e().catch(e=>u(String(e.message||e))),O=t=>D(async()=>{await f({message:`摘除「${t.label}」?${t.kind===`main`?`(只拆绑定,文档不删)`:`(文档不删,仅移出列表)`}`,danger:!0})&&(e===`repo`?await r(`/api/repos/docs`,{method:`DELETE`,body:{id:_,index:t.removeIndex}}):await r(`/api/docs/link`,{method:`POST`,body:{board:_,remove:t.removeIndex}}),u(`已摘除`),T(),l&&l())}),k=e=>D(async()=>{let t=await f({title:`标签 · ${e.label}`,input:!0,placeholder:`标签(如 qa;留空 = 清掉)`,value:e.tag||``,okText:`保存标签`});if(t===null)return;let n=typeof t==`string`?t:t&&t.tag||``;await g.setLinkTag(e.docId,n,e),u(n?`标签已设为 [${n}]`:`标签已清除`),T(),l&&l()}),A=()=>D(async()=>{if(!_||!String(g.docRef||``).startsWith(`rel:`)){u(`当前简介无法补充(需要自有树路径)`);return}let t=await f({title:`补充介绍文档`,input:!0,tagInput:!0,placeholder:`文档名(如 architecture / api-notes)`,tagPlaceholder:`标签(可选,如 qa)`});if(t===null)return;let n=typeof t==`string`?t:t&&t.value||``,i=typeof t==`object`&&t&&t.tag||``,a=ee(String(n).trim()||`note`).replace(/\.md$/i,``),o=`${U(g.docRef)||(e===`repo`?`repo/${_}`:`board/${v||_}`)}/reference/${a}.md`;await r(`/api/docs/item`,{method:`POST`,body:{rel:o,body:`# ${String(n).trim()||a}\n\n(待补)\n`}});try{e===`repo`?await r(`/api/repos/docs`,{method:`POST`,body:{id:_,rel:o,tag:i||void 0}}):await r(`/api/docs/link`,{method:`POST`,body:{board:_,doc:o,tag:i||void 0}})}catch{}u(`已补充:${o}${i?` [${i}]`:``}`),await T(),l&&l(),E({docId:`rel:`+o,label:String(n).trim()||a,sub:o})}),j=!!String(g.docRef||``).startsWith(`rel:`)&&_,M=y.length,N=`文档列表 · ${v||``}${e===`board`?`(项目组)`:``}`;return(0,I.jsxs)(i,{size:`md`,title:N,onClose:s,children:[(0,I.jsxs)(`div`,{className:`nx-dl`,children:[(0,I.jsxs)(`div`,{className:`nx-dl-head`,children:[(0,I.jsx)(`span`,{className:`nx-dl-count`,children:M?`${M} 篇`:`还没有文档`}),(0,I.jsx)(`span`,{className:`nx-dl-hint`,children:`点标题在主内容区打开`}),(0,I.jsx)(`span`,{className:`grow`}),j&&(0,I.jsx)(`button`,{type:`button`,className:`btn ghost sm nx-dl-add`,title:`补充一篇介绍文档(reference)`,onClick:A,children:`+ 补充`})]}),C?(0,I.jsx)(`div`,{className:`rpd-err`,children:C}):null,!C&&x&&M===0?(0,I.jsx)(`div`,{className:`rpd-empty`,children:`载入中…`}):null,!C&&!x&&M===0?(0,I.jsx)(`div`,{className:`rpd-none`,children:`还没有文档 —— 点「+ 补充」写第一篇`}):null,(0,I.jsx)(`div`,{className:`nx-dl-list`,children:y.map(e=>(0,I.jsxs)(`div`,{className:`nx-dl-row-wrap`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`nx-dl-row`,title:`${e.sub||e.label}\n点击在主内容区打开(可编辑)`,onClick:()=>E(e),children:[(0,I.jsxs)(`span`,{className:`nx-dl-row-title`,children:[ie[e.kind]||`○ `,e.label]}),e.tag?(0,I.jsx)(`span`,{className:`rpd-badge`,children:e.tag}):null]}),(0,I.jsxs)(`span`,{className:`nx-docs-modal-item-acts`,children:[e.taggable&&(0,I.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini`,title:e.tag?`改标签(当前:${e.tag})`:`加标签`,onClick:()=>k(e),children:`#`}),e.removable&&(0,I.jsx)(`button`,{type:`button`,className:`nx-docs-modal-mini danger`,title:e.removeTip||`摘除「${e.label}」(文档不删)`,onClick:()=>O(e),children:`×`})]})]},e.id))})]}),p]})}function X(e){return e<=1?18:e===2?12:8}function ae({headings:e=[],scrollRoot:t=null,links:n=[],activeDocId:r=``,onOpenDoc:i=null,onAddRef:a=null}){let[o,s]=(0,P.useState)(!1),[c,l]=(0,P.useState)(``),u=(0,P.useMemo)(()=>e||[],[e]),d=(0,P.useMemo)(()=>n||[],[n]);(0,P.useEffect)(()=>{let e=t;if(!e||!u.length)return;let n=()=>u.map(t=>{let n=e.querySelector(`#${CSS.escape(t.id)}`);if(!n)return null;let r=n.getBoundingClientRect(),i=e.getBoundingClientRect();return{id:t.id,y:r.top-i.top}}).filter(Boolean),r=()=>{let e=n();if(!e.length)return;let t=e[0].id;for(let n of e)n.y<=28&&(t=n.id);l(t)};return r(),e.addEventListener(`scroll`,r,{passive:!0}),()=>e.removeEventListener(`scroll`,r)},[t,u]);let f=(0,P.useCallback)(e=>{let n=t;if(!n)return;let r=n.querySelector(`#${CSS.escape(e)}`);if(!r){n.scrollTo({top:0,behavior:`smooth`}),l(e);return}r.scrollIntoView({behavior:`smooth`,block:`start`}),l(e)},[t]);return!u.length&&!d.length&&!a?null:(0,I.jsxs)(`aside`,{className:`doc-rail`+(o?` open`:``),"aria-label":`文档目录`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:o?`收起目录`:`展开目录`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{}),(0,I.jsx)(`span`,{})]}),(0,I.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`章节`,children:u.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(c===e.id?` on`:``),style:{"--tw":`${X(e.level)}px`},title:e.text,"aria-current":c===e.id?`true`:void 0,onClick:()=>f(e.id)},e.id))}),o&&(0,I.jsxs)(`div`,{className:`doc-rail-panel`,children:[u.length>0&&(0,I.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,I.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`本章`}),u.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`doc-rail-row`+(c===e.id?` on`:``),"data-lv":e.level,onClick:()=>f(e.id),children:e.text},e.id))]}),(d.length>0||a)&&(0,I.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,I.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`介绍文档`}),d.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(e.docId===r?` on`:``),title:e.note||e.label,disabled:!i,onClick:()=>i&&i(e.docId),children:[e.main?`● `:`○ `,e.label]},e.docId)),a&&(0,I.jsx)(`button`,{type:`button`,className:`doc-rail-add`,onClick:a,children:`+ 补充文档`})]})]})]})}function Z({kind:e,owner:t,model:n}){let{label:r,docRef:i,links:a,openMain:o}=G({kind:e,owner:t,model:n}),[s,c]=(0,P.useState)(!1);if(!t||!i)return null;let l=a.find(e=>e.main),u=l?l.docId:i,d=u.startsWith(`rel:`)?u.slice(4):u,f=a.filter(e=>!e.main).length;return(0,I.jsxs)(`div`,{className:`nx-intro`,children:[(0,I.jsxs)(`div`,{className:`nx-intro-head`,children:[(0,I.jsx)(`button`,{type:`button`,className:`nx-intro-link-main`,title:`打开${r}(在主内容区阅读 / 编辑)`,onClick:o,children:r}),(0,I.jsx)(`span`,{className:`nx-intro-path mono`,children:d}),(0,I.jsx)(`span`,{className:`nx-intro-spacer`}),(0,I.jsxs)(`button`,{type:`button`,className:`nx-intro-btn`,title:`查看${r}的全部文章(点标题在主内容区打开,可编辑)`,onClick:()=>c(!0),children:[`查看详情`,f>0?` ${f}`:``]})]}),s&&(0,I.jsx)(Y,{kind:e,owner:t,model:n,onClose:()=>c(!1)})]})}export{V as i,Y as n,B as r,Z as t};