nx-kv 0.64.0 → 0.65.2

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 (151) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/assets/nx-kv/SKILL.md +5 -2
  3. package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +6 -0
  4. package/assets/nx-kv/references/A04-/344/273/223/345/272/223/344/270/216/351/241/271/347/233/256/347/273/204.md +79 -6
  5. package/assets/nx-kv/templates/ref-main-doc.md +46 -0
  6. package/package.json +1 -1
  7. package/src/core/db/seed-templates.ts +2 -86
  8. package/src/modules/localtask/task-lifecycle.ts +1 -1
  9. package/src/modules/promptplug/actions/_manifest.generated.ts +9 -0
  10. package/src/modules/promptplug/actions/prompt-registry.ts +4 -1
  11. package/src/modules/promptplug/actions/prompt-template-activate.ts +31 -0
  12. package/src/modules/promptplug/actions/prompt-template-delete.ts +30 -0
  13. package/src/modules/promptplug/actions/prompt-template-save.ts +52 -0
  14. package/src/modules/promptplug/delivery.ts +151 -0
  15. package/src/modules/promptplug/factory.ts +16 -8
  16. package/src/modules/promptplug/index.ts +3 -1
  17. package/src/modules/promptplug/plugins/doneguard.ts +3 -0
  18. package/src/modules/promptplug/plugins/getloop.ts +8 -7
  19. package/src/modules/{tasktool/plugins/goal-template.ts → promptplug/plugins/goal-prompt.ts} +57 -4
  20. package/src/modules/promptplug/plugins/goal-shape.ts +17 -0
  21. package/src/modules/promptplug/plugins/goalhint.ts +22 -9
  22. package/src/modules/promptplug/plugins/timecheck.ts +25 -14
  23. package/src/modules/promptplug/registry.ts +3 -3
  24. package/src/modules/promptplug/template-store.ts +145 -0
  25. package/src/modules/tasktool/delivery.ts +231 -0
  26. package/src/modules/tasktool/get.ts +2 -2
  27. package/src/modules/tasktool/plugins/taskgoal-store.ts +28 -22
  28. package/src/modules/tasktool/plugins/timegoal-task-store.ts +70 -5
  29. package/src/modules/tasktool/plugins/waitgoal-config.ts +1 -25
  30. package/src/modules/tasktool/plugins/waitgoal.ts +0 -4
  31. package/src/modules/tasktool/preview.ts +3 -4
  32. package/src/modules/tasktool/wait.ts +16 -284
  33. package/src/modules/templates/actions/templates-default.ts +2 -5
  34. package/src/modules/templates/actions/templates-update.ts +1 -3
  35. package/src/modules/templates/service.ts +11 -13
  36. package/src/modules/templates/support.ts +0 -15
  37. package/src/web/frontend/App.tsx +0 -12
  38. package/src/web/frontend/api/cli-tree.json +58 -0
  39. package/src/web/frontend/api/client.generated.ts +32 -2
  40. package/src/web/frontend/components/doc/doc-head.tsx +13 -4
  41. package/src/web/frontend/components/icons.tsx +9 -199
  42. package/src/web/frontend/components/md/live-block.tsx +1 -5
  43. package/src/web/frontend/components/md/md-panes-root.tsx +0 -4
  44. package/src/web/frontend/components/md/md-panes.tsx +1 -11
  45. package/src/web/frontend/components/md/tool-bar.tsx +9 -0
  46. package/src/web/frontend/components/sidebar/index.tsx +13 -2
  47. package/src/web/frontend/components/sidebar/model.ts +3 -0
  48. package/src/web/frontend/components/tool-acts/bar.tsx +40 -29
  49. package/src/web/frontend/components/tool-acts/layout-panel.tsx +7 -3
  50. package/src/web/frontend/components/tool-acts/modules.ts +53 -51
  51. package/src/web/frontend/components/tool-acts/style.css +7 -3
  52. package/src/web/frontend/modules/md/styles/docs.css +0 -7
  53. package/src/web/frontend/modules/md/styles/editor.css +0 -17
  54. package/src/web/frontend/modules/md/styles/shell.css +3 -0
  55. package/src/web/frontend/modules/md/use-templates.ts +3 -13
  56. package/src/web/frontend/page/dir/index.tsx +3 -15
  57. package/src/web/frontend/page/dir/task-actions.ts +1 -16
  58. package/src/web/frontend/page/dir/task.tsx +2 -16
  59. package/src/web/frontend/page/group/index.tsx +6 -19
  60. package/src/web/frontend/page/repos/branch-persist.ts +32 -0
  61. package/src/web/frontend/page/repos/icons.tsx +47 -229
  62. package/src/web/frontend/page/repos/index.tsx +12 -8
  63. package/src/web/frontend/page/repos/repo-table.tsx +24 -3
  64. package/src/web/frontend/page/settings/api.ts +20 -0
  65. package/src/web/frontend/page/settings/index.tsx +1 -1
  66. package/src/web/frontend/page/settings/prompt-template-editor.tsx +180 -0
  67. package/src/web/frontend/page/settings/prompt-templates-section.tsx +39 -34
  68. package/src/web/frontend/page/settings/style.css +30 -0
  69. package/src/web/frontend/page/templates/index.tsx +5 -54
  70. package/src/web/frontend/page/templates/manage.tsx +1 -5
  71. package/src/web/frontend/page/templates/style.css +1 -43
  72. package/src/web/frontend/page/templates/template-list.tsx +7 -15
  73. package/src/web/frontend/routes/route-eq.ts +2 -3
  74. package/src/web/frontend/routes/static.ts +2 -2
  75. package/src/web/frontend/routes/templates.ts +0 -10
  76. package/src/web/frontend/styles/repos.css +22 -0
  77. package/src/web/frontend/styles-v2/shell.css +7 -0
  78. package/src/web/frontend/svghub/catalog-act.ts +168 -0
  79. package/src/web/frontend/svghub/catalog-doc.ts +102 -0
  80. package/src/web/frontend/svghub/catalog-nav.ts +192 -0
  81. package/src/web/frontend/svghub/catalog-repo.ts +102 -0
  82. package/src/web/frontend/svghub/catalog-state.ts +70 -0
  83. package/src/web/frontend/svghub/icon.tsx +95 -0
  84. package/src/web/frontend/svghub/index.ts +66 -0
  85. package/src/web/frontend/svghub/serialize.ts +39 -0
  86. package/src/web/frontend/svghub/types.ts +67 -0
  87. package/src/web/frontend/types.ts +2 -1
  88. package/src/web/public/assets/app-context-BqCBcDsx.js +1 -0
  89. package/src/web/public/assets/bar-Dc5Tq1eE.js +1 -0
  90. package/src/web/public/assets/{button-BEWXOABr.js → button-3JlUeln_.js} +1 -1
  91. package/src/web/public/assets/{composer-launch-DRi9mZE1.js → composer-launch-fp2IzGzQ.js} +1 -1
  92. package/src/web/public/assets/{composer-panel-swmDqlPw.js → composer-panel-Dh681iO6.js} +1 -1
  93. package/src/web/public/assets/dag-DnaU0I_z.js +1 -0
  94. package/src/web/public/assets/dir-d16q1GLe.js +3 -0
  95. package/src/web/public/assets/doc-DRSKD0Re.js +6 -0
  96. package/src/web/public/assets/group-Dc3ZgW24.js +1 -0
  97. package/src/web/public/assets/index-BIVxGd6t.css +1 -0
  98. package/src/web/public/assets/index-Bg0m8gbJ.js +2 -0
  99. package/src/web/public/assets/{list-filter-D-x94TvA.js → list-filter-CWxiOSg_.js} +1 -1
  100. package/src/web/public/assets/md-history-CLIs9Dr0.css +1 -0
  101. package/src/web/public/assets/md-history-DNtgaIdH.js +39 -0
  102. package/src/web/public/assets/{member-picker-Cvbv24IK.js → member-picker-BZgE3HGb.js} +1 -1
  103. package/src/web/public/assets/model-CtG2jIDv.js +2 -0
  104. package/src/web/public/assets/{overview-CctJfO3D.js → overview-C68QpcT9.js} +1 -1
  105. package/src/web/public/assets/popup-DZ2Khv2c.js +1 -0
  106. package/src/web/public/assets/progress-CEmAFxo9.js +3 -0
  107. package/src/web/public/assets/refs-TzxZYy7T.js +2 -0
  108. package/src/web/public/assets/repo-form-modal-Dg3hJWUV.js +1 -0
  109. package/src/web/public/assets/repos-uNqSR5YB.js +12 -0
  110. package/src/web/public/assets/{route-crumb-BcDPd7Ht.js → route-crumb-C4DgkJ8G.js} +1 -1
  111. package/src/web/public/assets/{settings-Cc6puKd5.css → settings-BWHjNegB.css} +1 -1
  112. package/src/web/public/assets/settings-BzIllshQ.js +1 -0
  113. package/src/web/public/assets/{status-tag-BD_0iWMB.js → status-tag-8cLH8hl9.js} +1 -1
  114. package/src/web/public/assets/task-DuFOXLPC.js +11 -0
  115. package/src/web/public/assets/{task-row-CQgzQmzu.js → task-row-CRjuAfKW.js} +1 -1
  116. package/src/web/public/assets/{task-utils-bJH1-Cjy.js → task-utils-DAPxKm4c.js} +1 -1
  117. package/src/web/public/assets/templates-CwYDIBYn.css +1 -0
  118. package/src/web/public/assets/templates-DNiGvmdq.js +10 -0
  119. package/src/web/public/assets/{use-rail-drag-ufwy2XZB.js → use-rail-drag-DxIYcszo.js} +1 -1
  120. package/src/web/public/assets/{workspace-D3jbcTwf.js → workspace-DojQ3RP4.js} +2 -2
  121. package/src/web/public/index.html +15 -16
  122. package/src/web/frontend/modules/md/fill-session.ts +0 -36
  123. package/src/web/frontend/modules/md/new-task-from-template.ts +0 -22
  124. package/src/web/frontend/modules/md/task-intent.ts +0 -29
  125. package/src/web/frontend/modules/prompts/render-template-body.ts +0 -14
  126. package/src/web/frontend/modules/prompts/template-preview.ts +0 -62
  127. package/src/web/frontend/page/templates/fill.tsx +0 -124
  128. package/src/web/public/assets/app-context-DDQnrPSP.js +0 -1
  129. package/src/web/public/assets/bar-j14ON7uZ.js +0 -1
  130. package/src/web/public/assets/dag-BzdFYMml.js +0 -1
  131. package/src/web/public/assets/dir-DhsB1ZhL.js +0 -3
  132. package/src/web/public/assets/doc-D4po3sDc.js +0 -6
  133. package/src/web/public/assets/fill-session-fHxQHFaD.js +0 -1
  134. package/src/web/public/assets/group-BxmSNzIB.js +0 -1
  135. package/src/web/public/assets/index-CMjG5NVU.js +0 -2
  136. package/src/web/public/assets/index-uMjSWNVr.css +0 -1
  137. package/src/web/public/assets/md-history-1h2zairf.css +0 -1
  138. package/src/web/public/assets/md-history-CZUF_FhN.js +0 -39
  139. package/src/web/public/assets/model-Cc2EoUQp.js +0 -2
  140. package/src/web/public/assets/new-task-from-template-DDWu4yR4.js +0 -1
  141. package/src/web/public/assets/popup-D8KWI6-Q.js +0 -1
  142. package/src/web/public/assets/progress-CawQRCQf.js +0 -3
  143. package/src/web/public/assets/refs-TuuoaRs7.js +0 -2
  144. package/src/web/public/assets/render-template-body-bXdedFig.js +0 -1
  145. package/src/web/public/assets/repo-form-modal-BD4N37MI.js +0 -1
  146. package/src/web/public/assets/repos-BPeuX4N9.js +0 -12
  147. package/src/web/public/assets/settings-CZJaKLZW.js +0 -1
  148. package/src/web/public/assets/task-DgbbF5gy.js +0 -11
  149. package/src/web/public/assets/task-intent-CX5DZccN.js +0 -1
  150. package/src/web/public/assets/templates-CBXlwyof.js +0 -11
  151. package/src/web/public/assets/templates-plA8R7jJ.css +0 -1
@@ -1,12 +0,0 @@
1
- import{c as e,d as t,i as n,l as r,m as i,r as a,s as o,t as s,u as c}from"./popup-D8KWI6-Q.js";import{r as l}from"./workspace-D3jbcTwf.js";import{C as u,D as d,E as f,O as p,S as m,T as h,_ as g,a as _,b as v,c as y,d as b,f as x,g as S,h as C,i as w,l as T,m as E,n as D,o as O,p as k,r as A,s as j,t as M,u as N,v as P,w as F,x as I,y as L}from"./repo-form-modal-BD4N37MI.js";import{n as R}from"./app-context-DDQnrPSP.js";import{t as z}from"./button-BEWXOABr.js";import{i as B,n as V}from"./doc-D4po3sDc.js";import{n as H,t as U}from"./list-filter-D-x94TvA.js";import{t as ee}from"./route-crumb-BcDPd7Ht.js";import{t as te}from"./bar-j14ON7uZ.js";import{t as ne}from"./member-picker-Cvbv24IK.js";var W=i(t(),1),G=c(),K={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function re({onClose:t,onChanged:n,repos:i,boards:a}){let s=o(),c=e(),[l,u]=(0,W.useState)(`import`),[d,f]=(0,W.useState)({}),[p,m]=(0,W.useState)({}),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(null),[C,w]=(0,W.useState)({}),[T,E]=(0,W.useState)({}),[D,O]=(0,W.useState)(`ours`),[k,A]=(0,W.useState)(`none`),[j,M]=(0,W.useState)(``),[N,P]=(0,W.useState)(null),[F,I]=(0,W.useState)(!1),L=(0,W.useMemo)(()=>i||[],[i]),R=(0,W.useMemo)(()=>L.map(e=>e.key),[L]),z=(0,W.useMemo)(()=>(a||[]).map(e=>e.name),[a]),B=e=>{let t={};for(let n of R)t[n]=e;f(t)},V=e=>{let t={};for(let n of z)t[n]=e;m(t)},H=()=>{let e={};for(let t of R)e[t]=!d[t];f(e)},U=()=>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!==R.length?e:void 0,boards:t.length&&t.length!==z.length?t.map(e=>`board/${e}`):void 0,noUnassigned:h},i=new URLSearchParams;n.repos?.length&&i.set(`repos`,n.repos.join(`,`)),n.boards?.length&&i.set(`boards`,n.boards.join(`,`)),h&&i.set(`no-unassigned`,`1`);let a=await r(`/api/repos/export`+(i.toString()?`?`+i:``));v(JSON.stringify(a,null,2)),c(`已生成布局:${a.repos.length} 个仓库 / ${a.boards.length} 个看板`)}),ee=()=>{if(!_)return;let e=new Blob([_],{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)},te=async e=>{let t=e.target.files?.[0];t&&(b(await t.text()),S(null),P(null))},ne=()=>s(async()=>{if(y.trim()){I(!0);try{let e=await r(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;E(n),P(null),c(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{I(!1)}}}),re=()=>s(async()=>{let e=Object.keys(C).filter(e=>C[e]),t=Object.keys(T).filter(e=>T[e]);I(!0);try{let i=await r(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:D,clone:k,selection:e.length?e:void 0,boards:t.length?t:void 0}});P(i),c(`导入完成:新建 ${i.created.length} · 覆盖 ${i.updated.length} · 另存 ${i.duplicated.length}`),await q(),n&&await n()}finally{I(!1)}}),q=(0,W.useCallback)(async()=>{try{let e=await r(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});S(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;w(t)}catch{}},[y]),ie=(0,W.useMemo)(()=>x?j?x.repos.filter(e=>e.status===j):x.repos:[],[x,j]),J=(e,t)=>s(async()=>{if(t){I(!0);try{await r(`/api/repos/clone`,{method:`POST`,body:{remote:t,key:e,type:`ref`,depth:1}}),c(`已克隆: ${e}`),await q(),n&&await n()}finally{I(!1)}}}),ae=e=>{let t={...C};for(let n of ie)t[n.key]=e;w(t)};(0,W.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,W.useMemo)(()=>{let e={new:0,changed:0,same:0};if(!x)return e;for(let t of x.repos)e[t.status]=(e[t.status]||0)+1;return e},[x]);return(0,G.jsx)(`div`,{className:`rp-full`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,G.jsxs)(`div`,{className:`rp-full-box`,children:[(0,G.jsxs)(`div`,{className:`rp-full-head`,children:[(0,G.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,G.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,G.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,G.jsx)(`button`,{className:`rp-tab`+(l===`import`?` on`:``),onClick:()=>u(`import`),children:`导入`}),(0,G.jsx)(`button`,{className:`rp-tab`+(l===`export`?` on`:``),onClick:()=>u(`export`),children:`导出`})]}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:t,children:`关闭`})]}),l===`export`?(0,G.jsxs)(`div`,{className:`rp-full-body`,children:[(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,G.jsx)(`span`,{children:`导出范围`}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!0),children:`全选仓库`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>B(!1),children:`全不选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:H,children:`反选`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-sel`,children:[L.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!d[e.key],onChange:t=>f(n=>({...n,[e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,G.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),L.length?null:(0,G.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,G.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,G.jsx)(`span`,{children:`看板`}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>V(!0),children:`全选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>V(!1),children:`全不选`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-sel`,children:[(a||[]).map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!p[e.name],onChange:t=>m(n=>({...n,[e.name]:t.target.checked}))}),(0,G.jsx)(`span`,{children:e.name})]},e.name)),a?.length?null:(0,G.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,G.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),(0,G.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(`button`,{className:`btn`,onClick:U,children:`生成布局`}),(0,G.jsx)(`button`,{className:`btn ghost`,disabled:!_,onClick:ee,children:`下载 JSON`})]})]}),(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`导出结果`})}),(0,G.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:_,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,G.jsxs)(`div`,{className:`rp-full-body`,children:[(0,G.jsxs)(`div`,{className:`rp-full-col`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`导入来源`})}),(0,G.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:te}),(0,G.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{b(e.target.value),S(null)}}),(0,G.jsx)(`div`,{className:`form-hint`,children:`每个仓库的 key 必须有:文件里已写 key 就直接用;只写了远程地址就按 host/owner/repo 归一化; 两样都没有会在差异检查阶段直接报错(不会按名字猜 key)。要改 key 就改上面的 JSON 再检查。`}),(0,G.jsx)(`div`,{className:`form-acts`,children:(0,G.jsx)(`button`,{className:`btn`,disabled:!y.trim()||F,onClick:ne,children:`差异检查`})}),x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,G.jsx)(`span`,{children:`冲突方案`})}),(0,G.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,G.jsx)(`input`,{type:`radio`,name:`strategy`,checked:D===e,onChange:()=>O(e)}),(0,G.jsx)(`span`,{children:t})]},e))}),(0,G.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,G.jsx)(`span`,{children:`克隆`})}),(0,G.jsxs)(`select`,{value:k,onChange:e=>A(e.target.value),children:[(0,G.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,G.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,G.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,G.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,G.jsx)(`div`,{className:`form-acts`,children:(0,G.jsxs)(`button`,{className:`btn`,disabled:F,onClick:re,children:[`执行导入(已选 `,Object.values(C).filter(Boolean).length,`)`]})})]}):null,N?(0,G.jsxs)(`div`,{className:`rp-import-result`,children:[(0,G.jsxs)(`div`,{children:[`新建 `,N.created.length,` · 覆盖 `,N.updated.length,` · 另存 `,N.duplicated.length,` · 跳过 `,N.skipped.length]}),(0,G.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,N.boardsCreated,` / 合并 `,N.boardsMerged,` · 参考关系 `,N.links]}),N.cloned.length?(0,G.jsxs)(`div`,{children:[`克隆 `,N.cloned.length,` 个`]}):null,N.unmatched.length?(0,G.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,N.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,G.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:x?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,G.jsxs)(`span`,{children:[`差异(新增 `,oe.new,` · 有差异 `,oe.changed,` · 一致 `,oe.same,x.summary.missing?` · 本地未拥有 ${x.summary.missing}`:``,`)`]}),(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(`button`,{className:`rp-chip`+(j===``?` on`:``),onClick:()=>M(``),children:`全部`}),(0,G.jsx)(`button`,{className:`rp-chip`+(j===`new`?` on`:``),onClick:()=>M(`new`),children:`新增`}),(0,G.jsx)(`button`,{className:`rp-chip`+(j===`changed`?` on`:``),onClick:()=>M(`changed`),children:`有差异`}),(0,G.jsx)(`button`,{className:`rp-chip`+(j===`same`?` on`:``),onClick:()=>M(`same`),children:`一致`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!0),children:`全选`}),(0,G.jsx)(`button`,{className:`btn small ghost`,onClick:()=>ae(!1),children:`全不选`})]})]}),(0,G.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,G.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{style:{width:`32px`}}),(0,G.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,G.jsx)(`th`,{children:`仓库 key`}),(0,G.jsx)(`th`,{children:`差异字段`})]})}),(0,G.jsxs)(`tbody`,{children:[ie.map(e=>(0,G.jsxs)(`tr`,{className:`rp-diff-row `+(K[e.status]?.cls??``),children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!C[e.key],onChange:t=>w(n=>({...n,[e.key]:t.target.checked}))})}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`span`,{className:`rp-status `+(K[e.status]?.cls??``),children:K[e.status]?.label})}),(0,G.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,G.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,G.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:F,onClick:()=>J(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,G.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`b`,{children:e.field}),`: `,(0,G.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,G.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,G.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),x.missing.map(e=>(0,G.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,G.jsx)(`td`,{}),(0,G.jsx)(`td`,{children:(0,G.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,G.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,G.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),x.boards.length?(0,G.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,G.jsx)(`div`,{className:`rp-full-colhead`,children:(0,G.jsx)(`span`,{children:`看板`})}),x.boards.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!T[e.key],onChange:t=>E(n=>({...n,[e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{className:`rp-status `+(K[e.status]?.cls??``),children:K[e.status]?.label}),(0,G.jsx)(`span`,{children:e.key}),(0,G.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers?.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),x.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,G.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,G.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,G.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,G.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,G.jsx)(`button`,{className:`btn small`,disabled:F,onClick:()=>J(e.key,e.remote),children:`克隆到本地`}):(0,G.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,G.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}var q=10;function ie({repo:t,onClose:n,onSaved:r}){let i=R(),a=e(),o=t.getLoop&&typeof t.getLoop==`object`?t.getLoop:null,[c,l]=(0,W.useState)(!!(o&&o.enabled)),[u,f]=(0,W.useState)(o&&o.waitMinutes!==void 0&&o.waitMinutes!==null?String(o.waitMinutes):String(q)),[p,m]=(0,W.useState)(!1),h=e=>{let t=String(e??``).trim();if(t===``)return q;let n=Number(t);return Number.isFinite(n)&&n>=0?Math.min(Math.floor(n),600):q},g=async e=>{m(!0);try{let n=e&&e.enabled!==void 0?e.enabled:c;await d(t.id,{"get-loop":n?`on`:`off`,...n?{"get-loop-minutes":h(u)}:{}});let o=h(u);a(n?`已保存「${t.name}」的持续 get 设置(${o>0?`${o} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`:`已关闭「${t.name}」的持续 get`),i.refreshRepos&&i.refreshRepos(),r&&r()}catch(e){a(String(e.message||e))}finally{m(!1)}},_=async e=>{l(e),await g({enabled:e})};return(0,G.jsx)(s,{title:`持续 get · ${t.name}`,onClose:n,size:`md`,children:(0,G.jsxs)(`div`,{className:`rp-gl`,children:[(0,G.jsxs)(`div`,{className:`rp-gl-head`,children:[(0,G.jsxs)(`div`,{className:`rp-gl-title`,children:[(0,G.jsx)(`span`,{className:`rp-gl-name`,children:`持续 get`}),(0,G.jsx)(`span`,{className:`rp-gl-desc`,children:`无任务时阻塞等待新任务回填(waitgoal)`})]}),(0,G.jsxs)(`button`,{className:`toggle`+(c?` on`:``),onClick:()=>_(!c),disabled:p,children:[(0,G.jsx)(`span`,{className:`dot`}),c?`开`:`关`]})]}),c&&(0,G.jsxs)(`div`,{className:`rp-gl-body`,children:[(0,G.jsxs)(`div`,{className:`rp-gl-row`,children:[(0,G.jsx)(`span`,{children:`阻塞窗口`}),(0,G.jsxs)(`span`,{className:`rp-gl-unit`,children:[(0,G.jsx)(`input`,{className:`rp-gl-min`,value:u,onChange:e=>f(e.target.value),inputMode:`numeric`,title:`0 = 不阻塞:没任务时 get 立即返回 timeout`}),`分钟`]})]}),(0,G.jsx)(`div`,{className:`rp-gl-note`,children:`这里只决定没有任务时 get 最多阻塞多久(0 = 不阻塞,立即返回 timeout)。领到任务后那段「继续 get 直到 timeout」的提示词是全局的,只有一份:要改文案去 设置 → 提示词模板 → 持续 get。`}),(0,G.jsxs)(`div`,{className:`rp-gl-acts`,children:[(0,G.jsx)(`span`,{className:`spacer`}),(0,G.jsx)(z,{variant:`primary`,disabled:p,onClick:()=>g(),children:`保存持续 get 设置`})]})]})]})})}function J({size:e=15,children:t,...n}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.6,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,...n,children:t})}function ae(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`circle`,{cx:`6`,cy:`5`,r:`2.2`}),(0,G.jsx)(`circle`,{cx:`6`,cy:`19`,r:`2.2`}),(0,G.jsx)(`circle`,{cx:`18`,cy:`12`,r:`2.2`}),(0,G.jsx)(`path`,{d:`M6 7.2v9.6`}),(0,G.jsx)(`path`,{d:`M6 12h6.6a2 2 0 0 1 2 2v-4a2 2 0 0 1 2-2`})]})}function oe(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`path`,{d:`M4 8.5 12 4l8 4.5v7L12 20l-8-4.5z`}),(0,G.jsx)(`path`,{d:`M4 8.5 12 13l8-4.5`}),(0,G.jsx)(`path`,{d:`M12 13v7`})]})}function se(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`path`,{d:`M3.5 9 10 5.4l6.5 3.6v5.6L10 18.2 3.5 14.6z`}),(0,G.jsx)(`path`,{d:`M3.5 9 10 12.8 16.5 9`}),(0,G.jsx)(`path`,{d:`M10 12.8v5.4`}),(0,G.jsx)(`path`,{d:`M15.5 17.5h5`}),(0,G.jsx)(`path`,{d:`M18.4 15.4 20.5 17.5l-2.1 2.1`})]})}function ce(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`path`,{d:`M6 3.5h7.2L18 8.3V20.5H6z`}),(0,G.jsx)(`path`,{d:`M13 3.5v5h5`}),(0,G.jsx)(`path`,{d:`M8.8 12.6h6.4M8.8 16.2h4.4`})]})}function le(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`path`,{d:`M8 6.5h9.5V21H8z`}),(0,G.jsx)(`path`,{d:`M5.5 17.5V3.5h9`}),(0,G.jsx)(`path`,{d:`M10.6 11h4.3M10.6 14.6h3`})]})}function ue(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`circle`,{cx:`10.8`,cy:`10.8`,r:`6`}),(0,G.jsx)(`path`,{d:`m15.3 15.3 4.2 4.2`})]})}function de(e){return(0,G.jsx)(J,{...e,children:(0,G.jsx)(`path`,{d:`M12 5.5v13M5.5 12h13`})})}function fe(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`path`,{d:`M19.5 12a7.5 7.5 0 1 1-2.6-5.7`}),(0,G.jsx)(`path`,{d:`M19.8 4.4v4.4h-4.4`})]})}function Y(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`path`,{d:`M13.5 4.5H20v6.5`}),(0,G.jsx)(`path`,{d:`M20 4.5 11.5 13`}),(0,G.jsx)(`path`,{d:`M17 14.5V20H4V7h5.5`})]})}function pe(e){return(0,G.jsx)(J,{...e,children:(0,G.jsx)(`path`,{d:`m7 10 5 5 5-5`})})}function me(e){return(0,G.jsx)(J,{...e,children:(0,G.jsx)(`path`,{d:`m5 12.5 4.6 4.5L19 7`})})}function he(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`circle`,{cx:`9.5`,cy:`8.5`,r:`3.2`}),(0,G.jsx)(`path`,{d:`M3.6 19.6c.6-3 3-4.6 5.9-4.6s5.3 1.6 5.9 4.6`}),(0,G.jsx)(`path`,{d:`M16 5.6a3 3 0 0 1 0 5.9`}),(0,G.jsx)(`path`,{d:`M17.4 15.3c2 .5 3.3 2 3.7 4.3`})]})}function ge(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`path`,{d:`M9.5 14.5 8 16a3.5 3.5 0 0 1-5-5l2.2-2.2`}),(0,G.jsx)(`path`,{d:`M14.5 9.5 16 8a3.5 3.5 0 0 1 5 5l-2.2 2.2`}),(0,G.jsx)(`path`,{d:`M9.8 14.2 14.2 9.8`})]})}function _e(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`rect`,{x:`3.6`,y:`3.6`,width:`7`,height:`7`,rx:`1.4`}),(0,G.jsx)(`rect`,{x:`13.4`,y:`3.6`,width:`7`,height:`7`,rx:`1.4`}),(0,G.jsx)(`rect`,{x:`3.6`,y:`13.4`,width:`7`,height:`7`,rx:`1.4`}),(0,G.jsx)(`rect`,{x:`13.4`,y:`13.4`,width:`7`,height:`7`,rx:`1.4`})]})}function ve(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`path`,{d:`M4.5 19.5h3.2l9.6-9.6a2.1 2.1 0 0 0 0-3l-1.7-1.7a2.1 2.1 0 0 0-3 0L3 14.8z`}),(0,G.jsx)(`path`,{d:`m13.4 6.6 4 4`})]})}function X(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`path`,{d:`M4.5 7h15`}),(0,G.jsx)(`path`,{d:`M9.5 7V4.8h5V7`}),(0,G.jsx)(`path`,{d:`M6.4 7l1 12.2h9.2L17.6 7`}),(0,G.jsx)(`path`,{d:`M10.2 10.6v6M13.8 10.6v6`})]})}function ye(e){return(0,G.jsxs)(J,{...e,children:[(0,G.jsx)(`path`,{d:`M10.2 13.8a3.6 3.6 0 0 0 5.1 0l2.6-2.6a3.6 3.6 0 0 0-5.1-5.1L11.6 7.3`}),(0,G.jsx)(`path`,{d:`M13.8 10.2a3.6 3.6 0 0 0-5.1 0l-2.6 2.6a3.6 3.6 0 0 0 5.1 5.1l1.2-1.2`})]})}function be({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,G.jsx)(p,{text:t,title:void 0,children:t}):(0,G.jsxs)(p,{text:t,title:`点击复制完整路径`,children:[(0,G.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function Z({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(`
2
- `):`查看完整文档列表(主篇 / 补充 / reference / 组内),可就地编辑`,o=(e,t)=>e.title||e.desc||`第 ${t+1} 篇`,s=[];return n&&n.exists&&s.push({id:`main`,label:o(n,0),kind:`repo`,main:!0,title:n.title||n.summary||``}),r.forEach((e,t)=>{s.push({id:(e.docId||e.refId||`link`)+`:`+t,label:o(e,t),kind:`repo`,title:String(e.title||e.desc||``)})}),(0,G.jsxs)(`div`,{className:`rp-docs-entry`,role:`button`,tabIndex:0,title:a,onClick:t,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&t()},children:[s.length?(0,G.jsx)(B,{items:s,onMore:t}):(0,G.jsx)(`span`,{className:`rp-docs-entry-main ghost`,children:`+ 写项目介绍`}),(0,G.jsx)(`span`,{className:`rp-docs-entry-n`,children:i>0?`${i} 篇 · 查看详情`:`查看详情`})]})}function xe({chips:e,acts:t}){let[n,r]=(0,W.useState)(!1),i=n?e:e.slice(0,4);return(0,G.jsxs)(G.Fragment,{children:[i.map(e=>(0,G.jsx)(`span`,{className:`rp-link-chip rp-link-chip-repo`,children:(0,G.jsxs)(`button`,{className:`rp-link-chip-main`,title:[`本仓库直接绑定的参考仓库`,`点击跳到这个参考仓库`].join(`
3
- `),onClick:()=>t.gotoRefRepo(e.key),children:[(0,G.jsx)(`b`,{children:`自`}),(0,G.jsx)(`span`,{className:`rp-link-chip-name`,children:e.name})]})},e.key)),e.length>4?(0,G.jsx)(`button`,{className:`rp-bind-more`,title:`展开本行全部参考仓库`,onClick:()=>r(e=>!e),children:n?`收起`:`+${e.length-4}`}):null]})}function Se({r:e,mode:t,filterBoard:n,refRepoChipsByRepo:r,acts:i}){let a=r.get(e.key)||[];return(0,G.jsxs)(`tr`,{id:`rp-row-`+e.key,children:[(0,G.jsxs)(`td`,{className:`rp-name`,children:[(0,G.jsxs)(`strong`,{children:[e.icon?(0,G.jsx)(`span`,{className:`rp-icon`,"aria-hidden":!0,children:e.icon}):null,e.name,e.getLoop&&e.getLoop.enabled?(0,G.jsx)(`span`,{className:`rp-gl-dot`,title:`持续 get 已开启(${Number(e.getLoop.waitMinutes)>0?`${Number(e.getLoop.waitMinutes)} 分钟阻塞窗口`:`不阻塞,没活立即返回`})`,"aria-label":`持续 get 已开启`}):null]}),(0,G.jsx)(`span`,{className:`mono rp-name-path`,children:(0,G.jsx)(be,{path:e.path})})]}),(0,G.jsx)(`td`,{className:`rp-cell-docs`,children:(0,G.jsx)(Z,{docs:e.descDocs,onOpen:()=>i.docs(e)})}),t===`group`?null:(0,G.jsxs)(`td`,{className:`rp-refs`,children:[a.length?(0,G.jsx)(xe,{chips:a,acts:i}):(0,G.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}),(0,G.jsx)(z,{small:!0,className:`rp-ref-bind`,title:`管理这个仓库绑定的参考仓库`,onClick:()=>i.bind(e),children:`绑定`})]}),(0,G.jsxs)(`td`,{className:`rp-acts`+(t===`group`?` rp-acts-wrap`:``),children:[(0,G.jsx)(te,{kind:`repos-row`,renderers:{edit:()=>(0,G.jsxs)(z,{small:!0,onClick:()=>i.edit(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(ve,{size:12})}),`编辑`]}),open:()=>(0,G.jsxs)(z,{small:!0,title:`在文件管理器中打开`,onClick:()=>i.open(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(Y,{size:12})}),`打开`]}),del:()=>(0,G.jsxs)(z,{small:!0,danger:!0,onClick:()=>i.del(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(X,{size:12})}),`删除`]}),getloop:()=>(0,G.jsx)(z,{small:!0,title:`持续 get(waitgoal)配置`,onClick:()=>i.getloop(e),children:(0,G.jsxs)(`span`,{className:`rp-gl-menu-it`,children:[e.getLoop&&e.getLoop.enabled?(0,G.jsx)(`span`,{className:`rp-gl-dot`,"aria-hidden":!0}):null,`持续 get…`]})}),remote:()=>(0,G.jsx)(z,{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:`删除仓库登记(磁盘文件不受影响)`}}),t===`group`&&n?(0,G.jsxs)(z,{small:!0,danger:!0,title:`只从这个分组摘除(不影响仓库本体与其它分组)`,onClick:()=>i.unbindBoard?.(e,n.id),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(ge,{size:12})}),`移出本组`]}):null]})]})}function Ce({shown:e,devRepos:t,mode:n,filterBoard:r,refRepoChipsByRepo:i,acts:a,onAddMember:o}){let s=n===`group`;return(0,G.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-repos`,children:(0,G.jsxs)(`table`,{className:`rp-table`+(s?` rp-table-group`:``),children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,style:{width:s?`30%`:`22%`},children:`仓库`}),(0,G.jsxs)(`th`,{scope:`col`,style:{width:s?`46%`:`34%`},children:[`文档`,(0,G.jsx)(`span`,{className:`rp-th-hint`,children:`主篇标题 · 查看详情打开完整文档列表`})]}),s?null:(0,G.jsx)(`th`,{scope:`col`,style:{width:`18%`},children:`参考仓库`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`322px`},children:`操作`})]})}),(0,G.jsxs)(`tbody`,{children:[e.map(e=>(0,G.jsx)(Se,{r:e,mode:n,filterBoard:r,refRepoChipsByRepo:i,acts:a},e.id)),e.length?null:(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:s?3:4,className:`muted rp-empty`,children:s?(0,G.jsxs)(G.Fragment,{children:[`这个分组里还没有仓库`,` `,r?(0,G.jsx)(z,{small:!0,onClick:()=>o(r.id),children:`添加成员`}):null]}):n==="default"?`没有未归组的仓库 —— 所有仓库都至少在一个分组里。`:t.length?`没有匹配的仓库:换个关键字,或切换分组看看。`:`还没有登记开发仓库 —— 点右上「登记仓库」加一条。`})})]})]})})}var we=`main`,Te=`default`;function Ee({branches:e,value:t,onChange:n,onCreate:r}){let[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(``),c=(0,W.useRef)(null),l=(0,W.useRef)(null),u=e.find(e=>e.id===t)||e[0];(0,W.useEffect)(()=>{if(!i)return;let e=e=>{c.current&&!c.current.contains(e.target)&&a(!1)},t=e=>{e.key===`Escape`&&(e.stopPropagation(),a(!1))};document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t,!0);let n=window.setTimeout(()=>l.current?.focus(),20);return()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t,!0),window.clearTimeout(n)}},[i]);let d=(0,W.useMemo)(()=>{let t=o.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||String(e.key||``).toLowerCase().includes(t)):e},[e,o]),f=e=>{a(!1),s(``),e!==t&&n(e)};return(0,G.jsxs)(`div`,{className:`rp-branch`,ref:c,children:[(0,G.jsxs)(`button`,{type:`button`,className:`rp-branch-btn`+(i?` open`:``),title:`切换分组:main = 全部仓库;其余项 = 项目组`,"aria-haspopup":`listbox`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[u&&u.virtual&&u.id===`main`?(0,G.jsx)(_e,{size:14}):(0,G.jsx)(ae,{size:14}),(0,G.jsx)(`span`,{className:`rp-branch-name`,children:u?u.name:we}),(0,G.jsx)(`span`,{className:`rp-branch-btn-caret`,children:(0,G.jsx)(pe,{size:13})})]}),i?(0,G.jsxs)(`div`,{className:`rp-branch-pop`,role:`listbox`,"aria-label":`分组`,children:[(0,G.jsxs)(`div`,{className:`rp-branch-filter`,children:[(0,G.jsx)(ue,{size:13}),(0,G.jsx)(`input`,{ref:l,value:o,placeholder:`筛选分组…`,"aria-label":`筛选分组`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d[0]&&f(d[0].id)}})]}),(0,G.jsxs)(`div`,{className:`rp-branch-list`,children:[d.map(e=>(0,G.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.id===t,className:`rp-branch-item`+(e.id===t?` on`:``),title:e.virtual?e.id===`main`?`全部:所有仓库 / 参考仓库 / 文档`:`没有归组的仓库都落在这里`:`项目组「${e.name}」`,onClick:()=>f(e.id),children:[(0,G.jsx)(`span`,{className:`rp-branch-item-ico`,children:e.virtual&&e.id===`main`?(0,G.jsx)(_e,{size:13}):(0,G.jsx)(ae,{size:13})}),(0,G.jsx)(`span`,{className:`rp-branch-item-name`,children:e.name}),(0,G.jsx)(`span`,{className:`rp-branch-item-n`,children:e.repoCount}),(0,G.jsx)(`span`,{className:`rp-branch-item-check`,children:e.id===t?(0,G.jsx)(me,{size:13}):null})]},e.id)),d.length?null:(0,G.jsx)(`div`,{className:`rp-branch-empty`,children:`没有匹配的分组`})]}),r?(0,G.jsxs)(`button`,{type:`button`,className:`rp-branch-new`,onClick:()=>{a(!1),s(``),r()},children:[(0,G.jsx)(de,{size:13}),(0,G.jsx)(`span`,{children:`新建分组`})]}):null]}):null]})}function De(e,t){if(!t||!e)return!1;let n=e.main;return n&&[n.title,n.summary,n.desc].some(e=>e&&String(e).toLowerCase().includes(t))?!0:(e.links||[]).some(e=>[e.title,e.desc].some(e=>e&&String(e).toLowerCase().includes(t)))}function Oe(e,t,n,r,i){let a;if(n){let t=new Set((n.repos||[]).filter(e=>e.present!==!1).map(e=>e.key));a=e.filter(e=>t.has(e.key))}else a=r==="default"?t:e;return i?a.filter(e=>[e.name,e.key,e.path,e.desc].some(e=>e&&String(e).toLowerCase().includes(i))||De(e.descDocs,i)):a}function Q(e,t,n,r){let i;if(t){let n=new Set((t.refs||[]).map(e=>e.id));i=e.filter(e=>n.has(e.key))}else i=n==="default"?[]:e;return r?i.filter(e=>[e.name,e.key,e.remote,e.path,e.desc].some(e=>e&&String(e).toLowerCase().includes(r))):i}function ke(e,t){let n=[{id:we,name:`main`,repoCount:t.dev,refCount:t.ref,docCount:t.docs||0,virtual:!0}];for(let t of e)n.push({id:t.id,name:t.name,key:t.key||t.id,repoCount:(t.repos||[]).filter(e=>e.present!==!1).length,refCount:(t.refs||[]).length,docCount:Number(t.docCount)||0});return n.push({id:Te,name:`default`,repoCount:t.ungrouped,refCount:0,docCount:0,virtual:!0}),n}function Ae({repos:e,boardList:t,branch:n,kw:r,docCount:i}){let a=(0,W.useMemo)(()=>e.filter(e=>(e.type||`dev`)!==`ref`),[e]),o=(0,W.useMemo)(()=>e.filter(e=>e.type===`ref`),[e]),s=(0,W.useMemo)(()=>t.find(e=>e.id===n)||null,[t,n]),c=(0,W.useMemo)(()=>a.filter(e=>!(e.boards||[]).length),[a]);return{devRepos:a,refRepos:o,branchBoard:s,ungrouped:c,branches:(0,W.useMemo)(()=>ke(t,{dev:a.length,ref:o.length,ungrouped:c.length,docs:i}),[t,a.length,o.length,c.length,i]),groupRefReposByRepo:(0,W.useMemo)(()=>{let e=new Map,n=new Map(o.map(e=>[e.key,e]));for(let r of t){let t=r.key||`board/${r.name}`;for(let i of(r.repos||[]).map(e=>e.key))for(let a of r.refs||[]){let o=n.get(a.id);if(!o)continue;e.has(i)||e.set(i,[]);let s=e.get(i);if(!s)continue;let c=s.find(e=>e.key===o.key);if(c){c.group&&c.group.name!==r.name&&(c.alsoIn=[...c.alsoIn||[],r.name]);continue}s.push({key:o.key,id:o.id,name:o.name,remote:o.remote||``,group:{id:r.id,key:t,name:r.name}})}}return e},[t,o]),refRepoChipsByRepo:(0,W.useMemo)(()=>{let e=new Map,t=new Map(o.map(e=>[e.key,e]));for(let n of a){let r=(n.linked||[]).filter(e=>e&&e.kind===`ref`).map(e=>{let n=t.get(e.id);return n?{key:n.key,name:n.name}:null}).filter(e=>e!==null);e.set(n.key,r)}return e},[a,o]),refRepoBackLinks:(0,W.useMemo)(()=>{let e=new Map;for(let t of a)for(let n of t.linked||[]){if(!n||n.kind!==`ref`)continue;e.has(n.id)||e.set(n.id,[]);let r=e.get(n.id);r&&r.push({repo:t})}return e},[a]),repoRows:(0,W.useMemo)(()=>Oe(a,c,s,n,r),[a,c,s,n,r]),refRows:(0,W.useMemo)(()=>Q(o,s,n,r),[o,s,n,r])}}function je({value:e,onChange:t,placeholder:n,count:r}){return(0,G.jsxs)(`label`,{className:`rp-q`,title:`全局检索:仓库 / 参考仓库 / 文档 一起搜`,children:[(0,G.jsx)(ue,{size:13}),(0,G.jsx)(`input`,{value:e,placeholder:n||`搜索仓库 / 参考仓库 / 文档…`,"aria-label":`全局检索`,onChange:e=>t(e.target.value)}),e?(0,G.jsx)(`span`,{className:`rp-q-n`,children:r===void 0?``:r}):null,e?(0,G.jsx)(`button`,{type:`button`,className:`rp-q-x`,title:`清空检索`,onClick:()=>t(``),children:`×`}):null]})}function Me({tabs:e,value:t,onChange:n}){return(0,G.jsx)(`div`,{className:`rp-blocks`,children:(0,G.jsx)(`div`,{className:`rp-block-tabs`,role:`tablist`,"aria-label":`区块`,children:e.map(e=>(0,G.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===t,disabled:e.disabled,className:`rp-block-tab`+(e.id===t?` on`:``),title:e.tip||`${e.label}(${e.count})`,onClick:()=>{!e.disabled&&e.id!==t&&n(e.id)},children:[(0,G.jsx)(`span`,{className:`rp-block-tab-ico`,children:e.icon}),(0,G.jsx)(`span`,{className:`rp-block-tab-label`,children:e.label}),(0,G.jsx)(`span`,{className:`rp-block-tab-n`,children:e.count})]},e.id))})})}function Ne({rows:e,mode:t,group:n,boardList:r,refRepoBackLinks:i,checkOf:a,onSync:o,onOpen:s,onDocs:c,onBind:l,onUnbindGroup:u,onUnbindRepo:d,onGoBind:f,onManage:m}){let h=t===`group`,[g,_]=(0,W.useState)({});return e.length?(0,G.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-refs`,children:(0,G.jsxs)(`table`,{className:`rp-table rp-table-ref`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,style:{width:`26%`},children:`参考仓库`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`24%`},children:`远程地址`}),(0,G.jsx)(`th`,{scope:`col`,children:`绑定对象`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`322px`},children:`操作`})]})}),(0,G.jsx)(`tbody`,{children:e.map(e=>{let t=a.get(e.id),m=r.map(t=>(t.refs||[]).find(t=>t.id===e.key)?{board:t}:null).filter(e=>e!==null),v=i.get(e.key)||[],y=!!g[e.id];return(0,G.jsxs)(`tr`,{id:`rp-refrepo-row-`+e.key,children:[(0,G.jsxs)(`td`,{className:`rp-ref-cell-name`,children:[(0,G.jsxs)(`strong`,{children:[(0,G.jsx)(`span`,{className:`rp-ref-dot`+(t?t.ok?` ok`:` bad`:``),title:t?t.ok?`检查通过`:(t.issues||[]).join(`
4
- `):`尚未检查`}),e.name]}),(0,G.jsx)(Z,{docs:e.descDocs,onOpen:()=>c(e)})]}),(0,G.jsx)(`td`,{className:`mono rp-ref-cell-remote`,children:(0,G.jsx)(p,{text:e.remote||``,title:`点击复制远程地址`,children:e.remote||`(无)`})}),(0,G.jsx)(`td`,{className:`rp-ref-cell-links`,children:m.length||v.length?(0,G.jsxs)(G.Fragment,{children:[m.length?(0,G.jsxs)(`div`,{className:`rp-bind-row`,children:[(0,G.jsx)(`span`,{className:`rp-bind-label`,children:`组`}),(y?m:m.slice(0,3)).map(t=>(0,G.jsxs)(`span`,{className:`rp-link-chip rp-link-chip-group`,children:[(0,G.jsxs)(`button`,{className:`rp-link-chip-main`,title:[`点击跳到这个分组`,`组级绑定(组内共享)`].join(`
5
- `),onClick:()=>f(`board`,t.board.id),children:[(0,G.jsx)(`b`,{children:`组`}),(0,G.jsx)(`span`,{className:`rp-link-chip-name`,children:t.board.name})]}),(0,G.jsx)(`button`,{className:`rp-link-chip-x`,title:`从这个分组摘除(不影响其它分组与仓库级绑定)`,onClick:()=>u(e,t.board.id),children:`×`})]},`board:`+t.board.id))]}):null,v.length?(0,G.jsxs)(`div`,{className:`rp-bind-row`,children:[(0,G.jsx)(`span`,{className:`rp-bind-label`,children:`仓`}),(y?v:v.slice(0,3)).map(t=>(0,G.jsxs)(`span`,{className:`rp-link-chip rp-link-chip-repo`,children:[(0,G.jsxs)(`button`,{className:`rp-link-chip-main`,title:[`直接绑定到这个仓库(不经过组)`,`仓库 key: ${t.repo.key}`,`点击定位到仓库行`].join(`
6
- `),onClick:()=>f(`repo`,t.repo.key),children:[(0,G.jsx)(`b`,{children:`仓`}),(0,G.jsx)(`span`,{className:`rp-link-chip-name`,children:t.repo.name})]}),(0,G.jsx)(`button`,{className:`rp-link-chip-x`,title:`从这个仓库摘除(不影响组级绑定)`,onClick:()=>d(e,t.repo.key),children:`×`})]},`repo:`+t.repo.key))]}):null,m.length+v.length>6?(0,G.jsx)(`button`,{className:`rp-bind-toggle`,onClick:()=>_(t=>({...t,[e.id]:!y})),children:y?`收起`:`展开全部 ${m.length+v.length}`}):null]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`muted rp-refs-none`,children:`未绑定`}),(0,G.jsx)(z,{small:!0,className:`rp-ref-bind`,onClick:()=>l(e),children:`绑定…`})]})}),(0,G.jsxs)(`td`,{className:`rp-acts rp-acts-wrap`,children:[(0,G.jsxs)(z,{small:!0,title:`拉取最新(git fetch / pull)`,onClick:()=>o(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(fe,{size:12})}),`同步`]}),(0,G.jsxs)(z,{small:!0,title:`在文件管理器中打开`,onClick:()=>s(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(Y,{size:12})}),`打开`]}),(0,G.jsxs)(z,{small:!0,title:`管理它绑在哪些组 / 仓库`,onClick:()=>l(e),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(ye,{size:12})}),`绑定…`]}),h&&n?(0,G.jsxs)(z,{small:!0,danger:!0,title:`只从这个分组摘除(不影响其它分组)`,onClick:()=>u(e,n.id),children:[(0,G.jsx)(`span`,{className:`rp-btn-ico`,children:(0,G.jsx)(ge,{size:12})}),`移出本组`]}):null]})]},e.id)})})]})}):(0,G.jsxs)(`div`,{className:`rp-block-empty`,children:[(0,G.jsx)(`div`,{className:`rp-block-empty-t`,children:h?`这个分组还没有参考仓库`:`还没有登记参考仓库`}),(0,G.jsx)(`div`,{className:`rp-block-empty-d`,children:`参考仓库是「拿来看的本机代码」——登记进来之后可以和开发仓库并列出现在任务上下文里。`}),(0,G.jsx)(z,{onClick:m,children:`打开参考仓库管理`})]})}function Pe({repos:t,boardList:r,q:i,onGoHost:a,tick:o,onCount:s,onShown:c}){let l=e(),{dialog:d,node:f}=n(),{openByDocId:p}=V(),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)([]),v=(0,W.useCallback)(async()=>{let e=await E().catch(()=>null),t=await k().catch(()=>null);h(e&&e.docs||[]),_(t&&t.bindings||[])},[]);(0,W.useEffect)(()=>{v()},[v,o]),(0,W.useEffect)(()=>{m&&s&&s(m.length)},[m,s]);let y=(0,W.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.key,{name:n.name||n.key,isRef:(n.type||`dev`)===`ref`});return e},[t]),b=(0,W.useMemo)(()=>{let e=new Map;for(let t of r)e.set(t.key||``,t.name),e.set(t.id,t.name);return e},[r]),x=(0,W.useCallback)(e=>{let t=[];for(let n of g){if(n.refId!==e)continue;let r=Number(n.position)===0?`(主篇)`:``;if(n.type===`repo`){let e=y.get(n.repoKey),i=e?e.isRef:n.hostKind===`ref`;t.push({text:`${i?`参考`:`仓`} · ${e?e.name:n.repoKey}${r}`,cls:i?`ref`:`repo`,kind:`repo`,target:n.repoKey,title:`${i?`参考仓库`:`开发仓库`}「${e?e.name:n.repoKey}」的文档列表`})}else if(n.type===`group`){let e=b.get(n.repoKey)||n.repoKey;t.push({text:`组 · ${e}${r}`,cls:`group`,kind:`group`,target:n.repoKey,title:`项目组「${e}」的文档列表`})}else{let e=b.get(n.groupKey||``)||n.groupKey||``,r=y.get(n.repoKey);t.push({text:`组内 · ${e} / ${r?r.name:n.repoKey}`,cls:`scoped`,kind:`group`,target:n.groupKey||``,title:`「${e}」里给仓库「${r?r.name:n.repoKey}」的组内描述`})}}return t},[g,y,b]),S=(0,W.useMemo)(()=>{let e=m||[],t=i.trim().toLowerCase();return t?e.filter(e=>[e.name,e.title,e.desc,e.summary].some(e=>e&&String(e).toLowerCase().includes(t))):e},[m,i]);if((0,W.useEffect)(()=>{m&&c&&c(S.length)},[S,m,c]),!m)return(0,G.jsx)(`div`,{className:`rp-block-empty`,children:(0,G.jsx)(`div`,{className:`rp-block-empty-t`,children:`读取中…`})});if(!m.length)return(0,G.jsxs)(`div`,{className:`rp-block-empty`,children:[(0,G.jsx)(`div`,{className:`rp-block-empty-t`,children:`还没有文档`}),(0,G.jsx)(`div`,{className:`rp-block-empty-d`,children:`文档挂在仓库 / 组的文档列表里,也可以从仓库行的「+ 写项目介绍」起一篇。`})]});let C=async e=>{let t=String(e.refId||``);if(!t){l(`这篇文档没有可删除的 refId`);return}if(!await d({message:`删除文档「${e.title||e.name||t}」?\n(自有文档,正文与归属一起删;不可恢复)`,danger:!0}))return;let n=await u({ref:t}).catch(e=>({error:String(e.message||e)}));if(n&&n.error){l(String(n.error));return}l(`已删除`),await v()},w=e=>{let t=String(e.docId||(e.refId?`ref:`+e.refId:``));if(!t){l(`这篇文档没有可打开的地址`);return}p(t)};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`rp-table-wrap`,id:`rp-docs`,children:(0,G.jsxs)(`table`,{className:`rp-table rp-table-doc`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,style:{width:`34%`},children:`文档`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`30%`},children:`归属`}),(0,G.jsx)(`th`,{scope:`col`,children:`摘要`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`84px`},children:`大小`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`52px`},"aria-label":`操作`})]})}),(0,G.jsxs)(`tbody`,{children:[S.map(e=>{let t=String(e.refId||``),n=t?x(t):[],r=e.title||e.name||`未命名文档`;return(0,G.jsxs)(`tr`,{className:`rp-docrow`,onClick:()=>w(e),title:`点击打开这篇文档(可编辑)`,children:[(0,G.jsxs)(`td`,{className:`rp-doc-cell-title`,children:[(0,G.jsxs)(`strong`,{children:[(0,G.jsx)(`span`,{className:`rp-doc-ico`,children:e.hasBody?(0,G.jsx)(ce,{size:13}):(0,G.jsx)(le,{size:13})}),r]}),e.desc?(0,G.jsx)(`span`,{className:`rp-doc-desc`,children:e.desc}):null,e.missing?(0,G.jsx)(`span`,{className:`rp-doc-miss`,title:e.reason||`没有正文`,children:e.reason||`无正文`}):null]}),(0,G.jsx)(`td`,{className:`rp-doc-cell-hosts`,children:n.length?(0,G.jsx)(`span`,{className:`rp-doc-badges`,children:n.map((e,t)=>(0,G.jsx)(`button`,{type:`button`,className:`rp-scope-badge `+e.cls,title:e.title+`
7
- 点击跳到这个宿主`,onClick:t=>{t.stopPropagation(),a(e.kind,e.target)},children:e.text},`${e.cls}:${e.target}:${t}`))}):(0,G.jsx)(`span`,{className:`rp-doc-orphan`,title:`没有绑到任何仓库 / 组:只在 main 的文档区块里能看到`,children:`未归属`})}),(0,G.jsx)(`td`,{className:`rp-doc-cell-summary`,children:(0,G.jsx)(`span`,{className:`rp-doc-summary`,title:e.summary||``,children:e.summary||`—`})}),(0,G.jsx)(`td`,{className:`rp-doc-cell-size mono`,children:e.size?`${Math.max(1,Math.round(Number(e.size)/1024))} KB`:`—`}),(0,G.jsx)(`td`,{className:`rp-doc-cell-acts`,children:(0,G.jsx)(`button`,{type:`button`,className:`rp-doc-del`,title:`删除这篇文档(自有文档;归属一并摘除)`,onClick:t=>{t.stopPropagation(),C(e)},children:`×`})})]},e.docId||t)}),S.length?null:(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:5,className:`muted rp-empty`,children:`没有匹配的文档:换个关键字。`})})]})]})}),f]})}function Fe({kw:e,q:t,repoRows:n,refRows:r,docShown:i,mode:a,branchBoard:o,boardList:s,repos:c,devRepos:l,refRepoChipsByRepo:u,refRepoBackLinks:d,checkOf:f,docTick:p,acts:m,onClear:h,onDocShown:g,onDocCount:_,onSync:v,onOpenRepo:y,onOpenDocs:b,onBindRef:x,onUnbindGroup:S,onUnbindRepo:C,onGoBind:w,onManageRefs:T,onAddMember:E,onGoHost:D}){let O=n.length+r.length+i;return(0,G.jsxs)(`div`,{className:`rp-sr`,children:[(0,G.jsxs)(`div`,{className:`rp-sr-head`,children:[(0,G.jsx)(`span`,{children:`搜索结果`}),(0,G.jsxs)(`span`,{className:`rp-sr-counts`,children:[`仓库 `,n.length,` · 参考仓库 `,r.length,` · 文档 `,i]}),(0,G.jsx)(`button`,{type:`button`,className:`rp-sr-clear`,onClick:h,children:`清除检索`})]}),O?null:(0,G.jsxs)(`div`,{className:`rp-block-empty`,children:[(0,G.jsxs)(`div`,{className:`rp-block-empty-t`,children:[`没有匹配「`,e,`」的结果`]}),(0,G.jsx)(`div`,{className:`rp-block-empty-d`,children:`换个关键词,或清除检索回到正常视图。`})]}),n.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rp-sr-sec`,children:[`仓库 `,n.length]}),(0,G.jsx)(Ce,{shown:n,devRepos:l,mode:a,filterBoard:o,refRepoChipsByRepo:u,acts:m,onAddMember:E})]}):null,r.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rp-sr-sec`,children:[`参考仓库 `,r.length]}),(0,G.jsx)(Ne,{rows:r,mode:a,group:o,boardList:s,refRepoBackLinks:d,checkOf:f,onSync:v,onOpen:y,onDocs:b,onBind:x,onUnbindGroup:S,onUnbindRepo:C,onGoBind:w,onManage:T})]}):null,(0,G.jsxs)(`div`,{className:`rp-sr-sec`,children:[`文档 `,i]}),(0,G.jsx)(Pe,{repos:c,boardList:s,q:t,tick:p,onGoHost:D,onCount:_,onShown:g})]})}function Ie({boards:t,devRepos:r,refRepos:i,reload:a}){let s=o(),c=e(),{dialog:l,node:u}=n(),d=(0,W.useMemo)(()=>{let e=new Map;for(let t of[...r,...i]){let n=String(t.path||``).split(/[\\/]/).filter(Boolean).pop()||``;for(let r of[t.name,n]){let n=String(r||``).toLowerCase();n&&!e.has(n)&&e.set(n,t)}}let n=[];for(let r of t&&t.boards||[])for(let t of r.repos||[]){if(t.present!==!1)continue;let i=String(t.key||``).split(`/`).filter(Boolean).pop()||``,a=e.get(String(t.name||``).toLowerCase())||e.get(i.toLowerCase())||null;n.push({...t,board:r.name,boardId:r.id,match:a})}return n},[t,r,i]),f=e=>s(async()=>{await _({remote:e.remote,key:e.key,name:e.name||void 0,type:`dev`}),c(`已克隆并登记:${e.name||e.key}`),a.repos(),a.boards()}),p=(e,t)=>s(async()=>{await m({from:e.key,to:t}),c(`已把「${e.name||e.key}」这个位置接到本机仓库`),a.repos(),a.boards()}),h=e=>s(async()=>{let t=await l({title:`把「${e.name||e.key}」接到哪个本机仓库?`,input:!0,placeholder:`本机仓库:id / key / 名称 / 绝对路径`});t&&(await m({from:e.key,to:t}),c(`已重绑——这个位置现在指向本机仓库`),a.repos(),a.boards())}),g=e=>s(async()=>{confirm(`把「${e.name||e.key}」从组「${e.board}」里移除?\n\n只摘这个组里的位置:本机仓库与看板本身都不动。`)&&(await D({key:e.key,board:e.boardId,remove:!0}),c(`已从组「${e.board}」移除`),a.boards())});return d.length?(0,G.jsxs)(`section`,{className:`rp-pending`,"data-testid":`rp-pending-init`,children:[(0,G.jsxs)(`header`,{className:`rp-pending-head`,children:[(0,G.jsxs)(`div`,{className:`rp-pending-head-main`,children:[(0,G.jsxs)(`h3`,{children:[`待初始化`,(0,G.jsx)(`span`,{className:`rp-pending-count`,children:d.length})]}),(0,G.jsx)(`p`,{children:`组里有位置、本机没有登记。接到本机仓库、克隆下来,或者直接移除。`})]}),(0,G.jsx)(z,{small:!0,onClick:()=>s(async()=>{let e=await L({apply:!1});if(!e?.total){c(`没有可清理的占位(有远程地址的那些留着等 clone)`);return}let t=e.items.map(e=>`· ${e.name}(组 ${e.board})`).join(`
8
- `);confirm(`清理 ${e.total} 个无来源占位?\n\n${t}\n\n它们没有远程地址,克隆不回来,只能删。`)&&(await L({apply:!0}),c(`已清理 ${e.total} 个占位`),a.boards())}),children:`清理无来源占位`})]}),(0,G.jsx)(`div`,{className:`rp-pending-list`,children:d.map(e=>(0,G.jsxs)(`article`,{className:`rp-pending-card`,children:[(0,G.jsxs)(`div`,{className:`rp-pending-info`,children:[(0,G.jsxs)(`div`,{className:`rp-pending-title`,children:[(0,G.jsx)(`strong`,{children:e.name||e.key}),(0,G.jsxs)(`span`,{className:`rp-pending-board`,children:[`组 · `,e.board]}),e.remote?null:(0,G.jsx)(`span`,{className:`rp-pending-tag`,children:`无远程地址`})]}),(0,G.jsx)(`code`,{className:`rp-pending-key`,children:e.key}),e.desc?(0,G.jsx)(`p`,{className:`rp-pending-desc`,children:e.desc}):null]}),(0,G.jsxs)(`div`,{className:`rp-pending-acts`,children:[e.match?(0,G.jsxs)(z,{small:!0,title:`把组里这个位置指向本机仓库「${e.match.name}」(仓库身份不变)`,onClick:()=>e.match&&p(e,e.match.id),children:[`绑定到「`,e.match.name,`」`]}):null,e.remote?(0,G.jsx)(z,{small:!0,onClick:()=>f(e),children:`克隆到本地`}):null,(0,G.jsx)(z,{small:!0,onClick:()=>h(e),children:`选本机仓库`}),(0,G.jsx)(z,{small:!0,danger:!0,title:`只从组里摘掉这个位置,本机仓库与看板都不动`,onClick:()=>g(e),children:`移除`})]})]},e.key+`@`+e.boardId))}),u]}):null}function Le({refRepos:t,devRepos:n,boardList:r,checkOf:i,refRepoBackLinks:a,refBindOpen:c,onRefBindOpen:l,onClose:u,onSyncOne:d,onUnbind:f,onUnbindRepo:m,onGoBind:g,onDocs:_,onRowAct:y,reload:b}){let x=o(),S=e(),[C,w]=(0,W.useState)(null),[T,E]=(0,W.useState)(!1),[D,O]=(0,W.useState)({gitRepoRoot:``,gitDevRoot:``}),[k,j]=(0,W.useState)(!1),[M,P]=(0,W.useState)({url:``,name:``,desc:``,depth:`1`}),[F,L]=(0,W.useState)({}),[R,B]=(0,W.useState)(null),[V,H]=(0,W.useState)({}),U=(0,W.useCallback)(async()=>{w(await N().catch(()=>null))},[]);(0,W.useEffect)(()=>{U()},[U]);let ee=()=>x(async()=>{let e={};D.gitRepoRoot.trim()&&(e.gitRepoRoot=D.gitRepoRoot.trim()),D.gitDevRoot.trim()&&(e.gitDevRoot=D.gitDevRoot.trim()),Object.keys(e).length&&(w(await h(e)),E(!1),S(`已保存存储根目录`))}),te=()=>x(async()=>{let e=M.url.trim();if(!e)return;let t={url:e,name:M.name.trim()||void 0,desc:M.desc.trim()||void 0,depth:parseInt(M.depth,10)||1,"no-bind":!0},i=n.filter(e=>F[`repo:`+e.id]).map(e=>e.id),a=r.filter(e=>F[`board:`+e.id]).map(e=>e.id);i.length&&(t.bind=i),a.length&&(t.board=a);let o=await v(t);j(!1),P({url:``,name:``,desc:``,depth:`1`}),L({}),S(`已克隆: ${o.name} → ${o.dest||o.path}`),await b.all()}),ne=()=>x(async()=>{let e=await I({all:!0}),t=e.results.filter(e=>e.status!==`updated`&&e.status!==`upToDate`);S(`同步 ${e.synced} 个${t.length?`,${t.length} 个有问题(见检查结果)`:`,全部完成`}`),await b.refCheck()}),K=e=>e.key||`board/${e.name}`,re=e=>{let t={};for(let n of r)(n.refs||[]).some(t=>t.id===e.key)&&(t[`board:`+K(n)]=!0);for(let r of n)(r.linked||[]).some(t=>t&&t.kind===`ref`&&String(t.id)===e.key)&&(t[`repo:`+r.key]=!0);H(t),B(e)};return(0,G.jsxs)(s,{size:`wide`,title:`参考仓库 · ${t.length}`,onClose:u,children:[(0,G.jsx)(`div`,{className:`rp-modal-bar`,children:(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(z,{small:!0,onClick:()=>{L({}),j(!0)},children:`克隆参考仓库`}),(0,G.jsx)(z,{small:!0,onClick:ne,children:`同步全部`}),(0,G.jsx)(z,{small:!0,onClick:b.refCheck,children:`检查`}),(0,G.jsx)(z,{small:!0,onClick:()=>{O({gitRepoRoot:C?.gitRepoRoot||``,gitDevRoot:C?.gitDevRoot||``}),E(!0)},children:`存储根`})]})}),C?.gitRepoRoot?null:(0,G.jsx)(`div`,{className:`rp-ref-warn`,children:`存储根未设置 —— 克隆会被拒绝。点「存储根」设一个非 C 盘目录(参考仓库体积不小,别放系统盘)。`}),(0,G.jsx)(`div`,{className:`rp-ref-table-wrap`,children:(0,G.jsxs)(`table`,{className:`rp-ref-table`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{scope:`col`,style:{width:`30px`}}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`17%`},children:`参考仓库`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`22%`},children:`远程地址`}),(0,G.jsx)(`th`,{scope:`col`,children:`绑定对象(仓库组 / 单独仓库 · 点击跳转)`}),(0,G.jsx)(`th`,{scope:`col`,style:{width:`220px`},children:`操作`})]})}),(0,G.jsxs)(`tbody`,{children:[t.map(e=>{let t=i.get(e.id),n=r.map(t=>(t.refs||[]).find(t=>t.id===e.key)?{board:t}:null).filter(e=>e!==null);return(0,G.jsxs)(`tr`,{id:`rp-refrepo-row-`+e.key,children:[(0,G.jsx)(`td`,{children:(0,G.jsx)(`span`,{className:`rp-ref-dot`+(t?t.ok?` ok`:` bad`:``),title:t?t.ok?`检查通过`:(t.issues||[]).join(`
9
- `):`尚未检查`})}),(0,G.jsxs)(`td`,{className:`rp-ref-cell-name`,children:[(0,G.jsx)(`strong`,{children:e.name}),(0,G.jsx)(Z,{docs:e.descDocs,onOpen:()=>_(e)})]}),(0,G.jsx)(`td`,{className:`mono rp-ref-cell-remote`,children:(0,G.jsx)(p,{text:e.remote||``,title:`点击复制远程地址`,children:e.remote||`(无)`})}),(0,G.jsx)(`td`,{className:`rp-ref-cell-links`,children:(()=>{let t=n,r=a.get(e.key)||[];if(!t.length&&!r.length)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`muted rp-refs-none`,children:`未绑定`}),(0,G.jsx)(z,{small:!0,className:`rp-ref-bind`,onClick:()=>re(e),children:`绑定…`})]});let i=!!c[e.id],o=i?t:t.slice(0,4),s=i?r:r.slice(0,4),u=t.length>4||r.length>4;return(0,G.jsxs)(G.Fragment,{children:[t.length?(0,G.jsxs)(`div`,{className:`rp-bind-row`,children:[(0,G.jsx)(`span`,{className:`rp-bind-label`,children:`仓库组`}),o.map(t=>(0,G.jsxs)(`span`,{className:`rp-link-chip rp-link-chip-group`,children:[(0,G.jsxs)(`button`,{className:`rp-link-chip-main`,title:[`点击跳到这个组`,`组级绑定(组内共享)`].join(`
10
- `),onClick:()=>g(`board`,t.board.id),children:[(0,G.jsx)(`b`,{children:`组`}),(0,G.jsx)(`span`,{className:`rp-link-chip-name`,children:t.board.name})]}),(0,G.jsx)(`button`,{className:`rp-link-chip-x`,title:`从本组摘除(不影响其它组、也不动仓库级绑定)`,onClick:()=>f(e,t.board.id),children:`×`})]},`board:`+t.board.id)),!i&&t.length>4?(0,G.jsxs)(`button`,{className:`rp-bind-more`,title:`展开本行全部绑定`,onClick:()=>l(t=>({...t,[e.id]:!0})),children:[`+`,t.length-4]}):null]}):null,r.length?(0,G.jsxs)(`div`,{className:`rp-bind-row`,children:[(0,G.jsx)(`span`,{className:`rp-bind-label`,children:`仓库`}),s.map(t=>(0,G.jsxs)(`span`,{className:`rp-link-chip rp-link-chip-repo`,children:[(0,G.jsxs)(`button`,{className:`rp-link-chip-main`,title:[`直接绑定到这个仓库(不经过组)`,`仓库 key: ${t.repo.key}`,`点击定位到仓库行`].join(`
11
- `),onClick:()=>g(`repo`,t.repo.key),children:[(0,G.jsx)(`b`,{children:`仓`}),(0,G.jsx)(`span`,{className:`rp-link-chip-name`,children:t.repo.name}),(0,G.jsx)(`span`,{className:`mono rp-link-chip-key`,children:t.repo.key})]}),(0,G.jsx)(`button`,{className:`rp-link-chip-x`,title:`从这个仓库摘除(不影响组级绑定)`,onClick:()=>m(e,t.repo.key),children:`×`})]},`repo:`+t.repo.key)),!i&&r.length>4?(0,G.jsxs)(`button`,{className:`rp-bind-more`,title:`展开本行全部绑定`,onClick:()=>l(t=>({...t,[e.id]:!0})),children:[`+`,r.length-4]}):null]}):null,u?(0,G.jsx)(`button`,{className:`rp-bind-toggle`,onClick:()=>l(t=>({...t,[e.id]:!i})),children:i?`收起`:`展开全部 ${t.length+r.length}`}):null,(0,G.jsx)(z,{small:!0,className:`rp-ref-bind`,onClick:()=>re(e),children:`绑定…`})]})})()}),(0,G.jsxs)(`td`,{className:`rp-acts`,children:[(0,G.jsx)(z,{small:!0,onClick:()=>d(e),children:`同步`}),(0,G.jsx)(z,{small:!0,onClick:()=>y(`open`,e),children:`打开`}),(0,G.jsx)(z,{small:!0,onClick:()=>y(`edit`,e),children:`编辑`}),(0,G.jsx)(z,{small:!0,danger:!0,onClick:()=>y(`del`,e),children:`删除`})]})]},e.id)}),t.length?null:(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:5,className:`muted rp-empty`,children:`还没有参考仓库 —— 点「克隆参考仓库」抓一个远程仓库下来(或用 CLI: nx-kv repo ref clone <url>)。`})})]})]})}),k?(0,G.jsx)(s,{title:`克隆参考仓库`,onClose:()=>{j(!1),L({})},children:(0,G.jsxs)(`div`,{className:`form-grid`,children:[(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`label`,{htmlFor:`ref-url`,children:`远程 git 地址 *`}),(0,G.jsx)(`input`,{id:`ref-url`,spellCheck:`false`,placeholder:`git@github.com:lib/x.git 或 https://github.com/lib/x`,value:M.url,onChange:e=>P(t=>({...t,url:e.target.value}))})]}),(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`label`,{htmlFor:`ref-name`,children:`名称`}),(0,G.jsx)(`input`,{id:`ref-name`,placeholder:`留空则用 URL 末段`,value:M.name,onChange:e=>P(t=>({...t,name:e.target.value}))})]}),(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`label`,{htmlFor:`ref-desc`,children:`它参考什么`}),(0,G.jsx)(`input`,{id:`ref-desc`,spellCheck:`false`,placeholder:`如:liquid glass 的官方实现参考`,value:M.desc,onChange:e=>P(t=>({...t,desc:e.target.value}))})]}),(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`label`,{children:`克隆后绑定到(可多选)`}),(0,G.jsxs)(`div`,{className:`rp-pick-list`,children:[(0,G.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,G.jsx)(`span`,{className:`rp-pick-group-label`,children:`开发仓库`}),n.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!F[`repo:`+e.id],onChange:t=>L(n=>({...n,[`repo:`+e.id]:t.target.checked}))}),(0,G.jsx)(`span`,{title:e.path,children:e.name})]},e.id)),n.length?null:(0,G.jsx)(`span`,{className:`muted`,children:`(还没有开发仓库)`})]}),(0,G.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,G.jsx)(`span`,{className:`rp-pick-group-label`,children:`看板(项目组)`}),r.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!F[`board:`+e.id],onChange:t=>L(n=>({...n,[`board:`+e.id]:t.target.checked}))}),(0,G.jsx)(`span`,{title:e.desc||``,children:e.name})]},e.id)),r.length?null:(0,G.jsx)(`span`,{className:`muted`,children:`(还没有看板)`})]})]}),(0,G.jsx)(`div`,{className:`form-hint`,children:`一个参考可同时服务多个仓库/组;之后随时在「绑定…」里增删。`})]}),(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(z,{onClick:()=>{j(!1),L({})},children:`取消`}),(0,G.jsx)(z,{disabled:!M.url.trim()||!C?.gitRepoRoot,title:C?.gitRepoRoot?`克隆到 ${C.gitRepoRoot}`:`先在「存储根」设置 gitRepoRoot`,onClick:te,children:`克隆`})]})]})}):null,R?(0,G.jsx)(s,{title:`绑定 · ${R.name}`,onClose:()=>B(null),children:(0,G.jsxs)(`div`,{className:`form-grid`,children:[(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`div`,{className:`form-hint`,children:`两类绑定并存、互不折算:勾「仓库组」= 组内共享(group_refs);勾「开发仓库」= 只绑这一个仓库(仓库级)。 取消勾选 = 摘除该维度(保存时对比差异)。`}),(0,G.jsxs)(`div`,{className:`rp-pick-list`,children:[(0,G.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,G.jsx)(`span`,{className:`rp-pick-group-label`,children:`仓库组`}),r.map(e=>{let t=K(e);return(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!V[`board:`+t],onChange:e=>H(n=>({...n,[`board:`+t]:e.target.checked}))}),(0,G.jsx)(`span`,{title:e.desc||``,children:e.name})]},e.id)}),r.length?null:(0,G.jsx)(`span`,{className:`muted`,children:`(还没有看板)`})]}),(0,G.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,G.jsx)(`span`,{className:`rp-pick-group-label`,children:`开发仓库(单独绑定)`}),n.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!V[`repo:`+e.key],onChange:t=>H(n=>({...n,[`repo:`+e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{title:e.path,children:e.name}),(0,G.jsx)(`span`,{className:`muted mono rp-pick-desc`,children:e.key})]},e.id)),n.length?null:(0,G.jsx)(`span`,{className:`muted`,children:`(还没有开发仓库)`})]})]})]}),(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(z,{onClick:()=>B(null),children:`取消`}),(0,G.jsx)(z,{onClick:()=>x(async()=>{if(!R)return;let e=e=>r.find(t=>K(t)===e.slice(6)),t=new Set([...r.filter(e=>(e.refs||[]).some(e=>e.id===R.key)).map(e=>`board:`+K(e)),...n.filter(e=>(e.linked||[]).some(e=>e&&e.kind===`ref`&&String(e.id)===R.key)).map(e=>`repo:`+e.key)]),i=new Set(Object.keys(V).filter(e=>V[e]));for(let n of i)if(!t.has(n)){if(n.startsWith(`board:`)){let t=e(n);if(!t)continue;await A({id:R.key,board:[t.id]})}else await A({id:R.key,repo:[n.slice(5)]})}for(let n of t)if(!i.has(n)){if(n.startsWith(`board:`)){let t=e(n);if(!t)continue;await A({id:R.key,board:[t.id],remove:!0})}else await A({id:R.key,repo:[n.slice(5)],remove:!0})}B(null),await Promise.all([b.repos(),b.boards(),b.refCheck()])}),children:`保存绑定`})]})]})}):null,T?(0,G.jsx)(s,{title:`参考仓库存储根`,onClose:()=>E(!1),children:(0,G.jsxs)(`div`,{className:`form-grid`,children:[(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`label`,{htmlFor:`roots-ref`,children:`参考仓库存储根(gitRepoRoot)`}),(0,G.jsx)(`input`,{id:`roots-ref`,spellCheck:`false`,placeholder:`如 D:/gitrepo-ref(非 C 盘)`,value:D.gitRepoRoot,onChange:e=>O(t=>({...t,gitRepoRoot:e.target.value}))}),(0,G.jsx)(`div`,{className:`form-hint`,children:`repo ref clone 的落盘位置。不设 = 克隆被拒绝。`})]}),(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`label`,{htmlFor:`roots-dev`,children:`开发仓库克隆根(gitDevRoot,可选)`}),(0,G.jsx)(`input`,{id:`roots-dev`,spellCheck:`false`,placeholder:`导入布局时开发仓库克隆到哪里`,value:D.gitDevRoot,onChange:e=>O(t=>({...t,gitDevRoot:e.target.value}))})]}),(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(z,{onClick:()=>E(!1),children:`取消`}),(0,G.jsx)(z,{onClick:ee,children:`保存`})]})]})}):null]})}function Re({boardList:t,unassigned:r,onClose:i,onFilter:a,onMembers:c,onOpenDoc:l,reload:u}){let d=o(),p=e(),{dialog:m,node:h}=n(),[g,_]=(0,W.useState)(null),[v,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(``),[w,T]=(0,W.useState)(null),E=()=>d(async()=>{if(!g)return;let e={name:g.name.trim()};e.name&&(g.id||(e.desc=g.desc.trim()||void 0),g.id?await f(encodeURIComponent(g.id),e):await O(e),_(null),await u.boards())}),D=e=>d(async()=>{await m({message:`删看板「${e.name}」?它里面的 ${(e.repos||[]).length} 个仓库**仍留在中心清单里**(只是少了一份归属)。`,danger:!0})&&(await j(encodeURIComponent(e.id)),await Promise.all([u.repos(),u.boards()]))});return(0,G.jsxs)(s,{size:`wide`,title:`分组管理 · ${t.length}`,onClose:i,children:[(0,G.jsxs)(`div`,{className:`rp-modal-bar`,children:[(0,G.jsxs)(`span`,{className:`acts`,children:[(0,G.jsx)(z,{small:!0,onClick:()=>_({id:null,name:``,desc:``}),children:`新建分组`}),(0,G.jsx)(z,{small:!0,title:`粘贴/选择看板 JSON`,onClick:()=>x(!0),children:`导入`}),(0,G.jsx)(z,{small:!0,title:`导出全部看板为 JSON`,onClick:()=>d(async()=>{let e=await y();T(JSON.stringify(e,null,2))}),children:`导出`})]}),(0,G.jsx)(`span`,{className:`muted`,children:`一个分组 = 一个主题;同一个仓库可以同时在多个分组里。`})]}),t.length?(0,G.jsxs)(`div`,{className:`rp-board-admin`,children:[(0,G.jsxs)(`div`,{className:`rp-board-admin-head`,children:[(0,G.jsx)(`span`,{children:`分组`}),(0,G.jsx)(`span`,{children:`成员`}),(0,G.jsx)(`span`,{children:`组介绍`}),(0,G.jsx)(`span`,{children:`操作`})]}),t.map(e=>{let t=(e.repos||[]).filter(e=>e.present!==!1),n=(e.repos||[]).filter(e=>e.present===!1);return(0,G.jsxs)(`div`,{className:`rp-board-admin-row`,children:[(0,G.jsxs)(`span`,{className:`rp-board-admin-name`,children:[e.name,(0,G.jsx)(`button`,{className:`rp-mini-link`,title:`只看「${e.name}」里的仓库`,onClick:()=>{a(e.id),i()},children:`筛选`})]}),(0,G.jsxs)(`span`,{className:`rp-board-admin-members`,children:[t.slice(0,4).map(e=>(0,G.jsx)(`span`,{className:`rp-board-mchip`,title:e.key,children:e.name||e.key},e.key)),t.length>4?(0,G.jsxs)(`span`,{className:`rp-board-more`,children:[`+`,t.length-4]}):null,n.length?(0,G.jsxs)(`span`,{className:`rp-board-missing`,children:[n.length,` 待初始化`]}):null,(e.repos||[]).length?null:(0,G.jsx)(`span`,{className:`muted`,children:`—`})]}),(0,G.jsxs)(`span`,{className:`rp-board-admin-doc`,children:[(0,G.jsx)(z,{small:!0,title:`在右侧栏列出这个组的文档`,onClick:()=>l(e),children:`文档`}),e.docCount&&e.docCount>1?(0,G.jsxs)(`span`,{className:`muted`,children:[`+`,e.docCount-1]}):null]}),(0,G.jsxs)(`span`,{className:`rp-board-admin-acts`,children:[(0,G.jsx)(`a`,{className:`btn small ghost`,href:`#/group/`+encodeURIComponent(e.id),title:`组页:成员与任务`,children:`组页 ↗`}),(0,G.jsx)(z,{small:!0,onClick:()=>c(e.id),children:`成员`}),(0,G.jsx)(z,{small:!0,onClick:()=>_({id:e.id,name:e.name,desc:e.desc||``}),children:`编辑`}),(0,G.jsx)(z,{small:!0,danger:!0,onClick:()=>D(e),children:`删除`})]})]},e.id)}),r?.length?(0,G.jsxs)(`div`,{className:`rp-boards-unassigned`,children:[`未分组 `,(0,G.jsx)(`b`,{children:r.length}),` 个 —— 不属于任何分组,只在「全部」里可见。`]}):null]}):(0,G.jsx)(`div`,{className:`rp-board-empty muted`,children:`还没有分组 —— 点「新建分组」建一个当主题用(如「前端」「AI 工具」),再把仓库点选进去。`}),g?(0,G.jsx)(s,{title:g.id?`编辑看板`:`新建看板`,onClose:()=>_(null),children:(0,G.jsxs)(`div`,{className:`form-grid`,children:[(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`label`,{htmlFor:`bd-name`,children:`看板名称 *`}),(0,G.jsx)(`input`,{id:`bd-name`,placeholder:`如 前端 / AI 工具`,value:g.name,onChange:e=>_(t=>t&&{...t,name:e.target.value})})]}),g.id?(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`label`,{children:`领域描述(文档)`}),(0,G.jsx)(`div`,{className:`rp-docpick`,children:(0,G.jsx)(`button`,{type:`button`,className:`rp-doc`+(g.desc?``:` ghost`),title:`打开右侧栏文档列表(组介绍在里面维护)`,onClick:()=>{let e=t.find(e=>e.id===g?.id);_(null),e&&l(e)},children:g.desc||`未写`})})]}):(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`label`,{htmlFor:`bd-desc`,children:`初始描述`}),(0,G.jsx)(`textarea`,{id:`bd-desc`,rows:3,spellCheck:`false`,placeholder:`新建时给的介绍正文(之后在组介绍文档里继续维护)。
12
- 如:这组仓库在这个环境里的侧重、配合关系、关键路径与搜索关键词。`,value:g.desc,onChange:e=>_(t=>t&&{...t,desc:e.target.value})})]}),(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(z,{onClick:()=>_(null),children:`取消`}),(0,G.jsx)(z,{disabled:!g.name.trim(),onClick:E,children:g.id?`保存`:`新建看板`})]})]})}):null,v?(0,G.jsx)(s,{title:`导入看板 JSON`,size:`lg`,onClose:()=>{x(!1),C(``)},children:(0,G.jsxs)(`div`,{className:`form-grid`,children:[(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`label`,{htmlFor:`bd-imp`,children:`看板 JSON`}),(0,G.jsxs)(`div`,{className:`form-hint`,children:[`结构 `,`{ boards:[{ name, repos:[{ path|name }] }] }`,` —— 按 path 或 name 匹配已登记仓库,匹配不上的会如实报告`]}),(0,G.jsx)(`input`,{id:`bd-imp-file`,type:`file`,accept:`.json,application/json`,onChange:async e=>{let t=e.target.files?.[0];t&&C(await t.text())}}),(0,G.jsx)(`textarea`,{id:`bd-imp`,rows:10,spellCheck:`false`,placeholder:`{"boards":[{"name":"前端","repos":[{"path":"D:/code/a_js/proj/nx-ft"}]}]}`,value:S,onChange:e=>C(e.target.value)})]}),(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(z,{onClick:()=>{x(!1),C(``)},children:`取消`}),(0,G.jsx)(z,{disabled:!S.trim(),onClick:()=>d(async()=>{if(!S.trim())return;let e=await b({json:S});x(!1),C(``),p(`已导入:新建 ${e.created} 个看板、合并 ${e.merged} 个、匹配仓库 ${e.matched} 个`+(e.unmatched.length?`;未匹配 ${e.unmatched.length} 条(见 CLI board import 输出)`:``)),await Promise.all([u.repos(),u.boards()])}),children:`导入`})]})]})}):null,w?(0,G.jsx)(s,{title:`看板 JSON(可回灌给导入)`,size:`lg`,onClose:()=>T(null),children:(0,G.jsx)(`textarea`,{className:`bd-exp`,rows:14,readOnly:!0,value:w,spellCheck:`false`})}):null,h]})}function ze({repo:t,refRepos:n,boardList:r,currentRefs:i,onClose:a,onSaved:c}){let l=o(),u=e(),d=r.filter(e=>(e.repos||[]).some(e=>e.key===t.key)),[f,p]=(0,W.useState)(()=>{let e={};for(let t of i||[])e[t.key]=!0;return e}),[m,h]=(0,W.useState)(``),g=U(n,m,e=>[e.name,e.key,e.desc]);return(0,G.jsx)(s,{title:`「${t.name}」的参考仓库`,onClose:a,children:(0,G.jsxs)(`div`,{className:`form-grid`,children:[(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsxs)(`div`,{className:`form-hint`,children:[`参考仓库绑定在组上,勾选 = 绑到「`,t.name,`」所属的组,组内所有仓库共享。仓库不属于任何组时请先把它加入组。`]}),(0,G.jsx)(`div`,{className:`rp-pick-list`,children:(0,G.jsxs)(`div`,{className:`rp-pick-group`,children:[(0,G.jsx)(`span`,{className:`rp-pick-group-label`,children:`参考仓库`}),n.length>1?(0,G.jsx)(H,{value:m,onChange:h,placeholder:`搜索参考仓库…`,title:`过滤参考仓库`,count:g.length,className:`wide`}):null,g.map(e=>(0,G.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!f[e.key],onChange:t=>p(n=>({...n,[e.key]:t.target.checked}))}),(0,G.jsx)(`span`,{title:e.remote||``,children:e.name}),e.desc?(0,G.jsx)(`span`,{className:`muted rp-pick-desc`,children:e.desc}):null]},e.key)),n.length?g.length?null:(0,G.jsx)(`span`,{className:`muted`,children:`(没有匹配的参考仓库)`}):(0,G.jsx)(`span`,{className:`muted`,children:`(还没有参考仓库 —— 先在参考面板里克隆)`})]})}),d.length?(0,G.jsxs)(`div`,{className:`form-hint`,children:[`将写入:`,d.map(e=>e.name).join(`、`)]}):(0,G.jsx)(`div`,{className:`form-hint rp-ref-warn`,children:`这个仓库不属于任何组,保存会被拒绝 —— 先把它加入组。`})]}),(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(z,{onClick:a,children:`取消`}),(0,G.jsx)(z,{onClick:()=>l(async()=>{if(!d.length){u(`这个仓库不属于任何组 —— 参考绑定挂在组上;先把它加入组`);return}let e=new Set((i||[]).map(e=>e.key)),t=new Set(Object.keys(f).filter(e=>f[e]));for(let n of t)if(!e.has(n))for(let e of d)await A({id:n,board:[e.id]});for(let n of e)if(!t.has(n))for(let e of d)await A({id:n,board:[e.id],remove:!0});a(),await c()}),children:`保存绑定`})]})]})})}function Be({repo:t,onClose:n,onSaved:r}){let i=o(),a=e(),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(null),f=(0,W.useCallback)(async()=>{try{let e=await C(t.key);if(!e||!Array.isArray(e.remotes))throw Error(`远程地址读取失败`);l(e)}catch(e){a(String(e.message||e)),n()}},[t.key,a,n]);(0,W.useEffect)(()=>{f()},[f]);let p=e=>i(async()=>{c&&(await P({id:c.key,url:e}),n(),a(`已对齐 remote`),await r())}),m=async e=>{let t=c?c.key:``;if(!t){d({url:``,status:`unreachable`,detail:`没有仓库标识`});return}d({url:e||c?.current||``,status:`checking`,detail:`检查中…`});try{let n=await w(t,e);d(n)}catch(t){d({url:e||c?.current||``,status:`unreachable`,detail:String(t.message||t)})}};return c?(0,G.jsx)(s,{title:`对齐 remote · ${c.name}`,onClose:n,children:(0,G.jsxs)(`div`,{className:`form-grid`,"data-testid":`rp-remote-modal`,children:[(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsxs)(`div`,{className:`form-hint`,children:[`当前采纳:`,(0,G.jsx)(`b`,{children:c.current||`(无)`}),`。换一条即对齐(key 随之重算;自定义 key 不动)。`]}),(0,G.jsxs)(`div`,{className:`rp-remote-list`,children:[c.remotes.map(e=>(0,G.jsxs)(`div`,{className:`rp-remote-item`,children:[(0,G.jsx)(`span`,{className:`rp-remote-name`,children:e.name}),(0,G.jsx)(`span`,{className:`mono rp-remote-url`,children:e.url}),(0,G.jsx)(`span`,{className:`rp-remote-kind`,children:e.kind}),e.current?(0,G.jsx)(`span`,{className:`rp-remote-on`,children:`当前`}):null,(0,G.jsxs)(`span`,{className:`acts`,children:[e.current?null:(0,G.jsx)(z,{small:!0,onClick:()=>p(e.url),children:`对齐这条`}),(0,G.jsx)(z,{small:!0,onClick:()=>m(e.url),children:`检查`})]})]},e.name+`|`+e.url)),c.remotes.length?null:(0,G.jsx)(`div`,{className:`muted`,children:`这个仓库没有配置 remote —— 先在 git 里 git remote add`})]})]}),u?(0,G.jsxs)(`div`,{className:`form-field`,children:[(0,G.jsx)(`label`,{children:`存在性检查`}),(0,G.jsxs)(`div`,{className:`rp-remote-check`,children:[(0,G.jsx)(`span`,{className:`rp-status `+(u.status===`exists`?`same`:u.status===`missing`?`new`:u.status===`checking`?`checking`:`missing`),children:u.status===`exists`?`存在`:u.status===`missing`?`不存在`:u.status===`checking`?`检查中`:`不可达`}),(0,G.jsx)(`span`,{className:`mono rp-remote-url`,children:u.url}),(0,G.jsx)(`span`,{className:`muted`,children:u.detail})]})]}):null,(0,G.jsxs)(`div`,{className:`form-acts`,children:[(0,G.jsx)(z,{onClick:n,children:`关闭`}),(0,G.jsx)(z,{onClick:()=>m(``),children:`检查当前 remote`})]})]})}):null}function Ve(){let t=o(),r=e(),{dialog:i,node:s}=n(),c=R(),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(0),[m,h]=(0,W.useState)(0),[_,v]=(0,W.useState)([]),[y,b]=(0,W.useState)(null),[C,w]=(0,W.useState)(null),D=(0,W.useCallback)(async()=>{v(await S().catch(()=>[])||[])},[]),k=(0,W.useCallback)(async()=>{b(await x().catch(()=>null))},[]),j=(0,W.useCallback)(async()=>{w(await T().catch(()=>null))},[]),N=(0,W.useCallback)(async()=>{let e=await E().catch(()=>null);d(e&&Array.isArray(e.docs)?e.docs.length:null)},[]);(0,W.useEffect)(()=>{D(),k(),j()},[D,k,j]),(0,W.useEffect)(()=>{N()},[N,m]);let P=(0,W.useMemo)(()=>({repos:D,boards:k,refCheck:j,all:async()=>{await Promise.all([D(),k(),j()])}}),[D,k,j]),[L,z]=(0,W.useState)(we),[B,V]=(0,W.useState)(`repos`),[H,U]=(0,W.useState)(``),[K,q]=(0,W.useState)(void 0),[J,ue]=(0,W.useState)(!1),[de,Y]=(0,W.useState)(!1),[pe,me]=(0,W.useState)(``),[ge,_e]=(0,W.useState)({}),[ve,X]=(0,W.useState)(null),[ye,be]=(0,W.useState)(!1),[Z,xe]=(0,W.useState)(null),[Se,Te]=(0,W.useState)(null),[De,Oe]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=()=>{let e=location.hash.split(`?`)[1]||``;if(!e)return;let t=new URLSearchParams(e),n=t.get(`board`);n&&(z(n),V(`repos`),t.get(`add`)&&X(n))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let Q=(0,W.useMemo)(()=>y&&y.boards||[],[y]),ke=H.trim().toLowerCase(),{devRepos:Ve,refRepos:He,branchBoard:$,branches:Ue,groupRefReposByRepo:We,refRepoChipsByRepo:Ge,refRepoBackLinks:Ke,repoRows:qe,refRows:Je}=Ae({repos:_,boardList:Q,branch:L,kw:ke,docCount:u}),Ye=(0,W.useMemo)(()=>{let e=new Map;return(C?.refRepos||[]).forEach(t=>e.set(t.id,t)),e},[C]),Xe=(0,W.useMemo)(()=>Q.find(e=>e.id===ve)||null,[Q,ve]);(0,W.useEffect)(()=>{if(!de||!pe)return;let e=null,t=0,n=requestAnimationFrame(()=>{e=document.getElementById(`rp-refrepo-row-`+pe),e&&(e.scrollIntoView({block:`center`}),e.classList.add(`rp-row-flash`),t=window.setTimeout(()=>e?.classList.remove(`rp-row-flash`),1600))});return()=>{cancelAnimationFrame(n),clearTimeout(t),e&&e.classList.remove(`rp-row-flash`)}},[de,pe]);let Ze=e=>t(async()=>{let t=await I({id:e.id});r(t.status===`updated`?`已更新: ${t.name}`:t.status===`upToDate`?`${t.name} 已是最新`:`${t.name}: ${t.status} ${t.output||``}`)}),Qe=(e,n)=>t(async()=>{await A({id:e.key,board:[n],remove:!0}),await Promise.all([D(),k(),j()])}),$e=(e,n)=>t(async()=>{await A({id:e.key,repo:[n],remove:!0}),await Promise.all([D(),k(),j()])}),et=(e,n)=>t(async()=>{await A({id:e.key,board:[n],remove:!0}),await Promise.all([D(),k()])}),tt=e=>{let t=c.model;if(!t){r(`工作区不可用,无法打开文档列表`);return}l(t,{component:`refs`,name:`文档列表`,config:{repoKey:e.key||``,repoName:e.name||``,scope:`repo`},location:`right`})},nt=(e,t=!1)=>{let n=c.model;if(!n){r(`工作区不可用,无法打开文档列表`);return}l(n,{component:`refs`,name:`文档列表`,config:{boardKey:e.key||e.id||``,boardName:e.name||``,scope:`all`},location:`right`}),t||r(`「${e.name}」的文档在右侧「文档列表」里`)},rt=(e,n)=>t(async()=>{if(e===`open`)await g({id:n.id});else if(e===`del`){if(!await i({message:`删除仓库登记「${n.name}」?(仅移除登记,磁盘文件不受影响;各分组里的归属同步摘除)`,danger:!0}))return;await F(encodeURIComponent(n.id)),await P.all(),h(e=>e+1)}}),it=()=>t(async()=>{let e=await i({title:`新建分组`,input:!0,placeholder:`分组名(例如 远程控制)`}),t=String(e||``).trim();if(!t)return;let n=await O({name:t});await k(),n&&n.id&&(z(n.id),V(`repos`),U(``)),r(`已建分组「${t}」——把仓库加进来就是这一组的成员`)}),at=(e,t=`start`)=>{if(!e)return;let n=e.parentElement;for(;n;){let e=getComputedStyle(n);if((e.overflowY===`auto`||e.overflowY===`scroll`)&&n.scrollHeight>n.clientHeight)break;n=n.parentElement}n||=document.scrollingElement||document.documentElement;let r=n.getBoundingClientRect?n.getBoundingClientRect().top:0,i=e.getBoundingClientRect().top-r,a=t===`center`?(n.clientHeight-e.offsetHeight)/2:12;n.scrollTop=Math.max(0,n.scrollTop+i-a)},ot=(e,t)=>{if(e===`group`){let e=Q.find(e=>e.key===t||e.id===t);if(!e){r(`这个组已经不存在了`);return}z(e.id),V(`repos`),U(``);return}let n=Ve.find(e=>e.key===t)||He.find(e=>e.key===t);if(!n){r(`这个仓库已经不在登记里了`);return}if($&&!($.repos||[]).some(e=>e.key===t)){let e=(n.boards||[])[0];z(e?e.id:we)}V(n.type===`ref`?`refs`:`repos`),U(``),window.setTimeout(()=>{let e=document.getElementById(`rp-row-`+t)||document.getElementById(`rp-refrepo-row-`+t);e&&(at(e,`center`),e.classList.add(`rp-row-flash`),window.setTimeout(()=>e.classList.remove(`rp-row-flash`),1400))},60)},st={open:e=>rt(`open`,e),edit:e=>q(e.id),del:e=>rt(`del`,e),remote:e=>{if(!e.key){r(`这个仓库还没有 key —— 先 nx-kv repo key set <id> <key>`);return}Te(e)},getloop:e=>xe(e),docs:e=>tt(e),filter:e=>z(e),gotoRefRepo:e=>{me(e),Y(!0)},bind:e=>Oe(e),unbindBoard:et},ct=[{id:`repos`,label:`仓库`,count:qe.length,icon:(0,G.jsx)(oe,{size:14}),tip:`开发仓库(本机 git 目录)`},{id:`refs`,label:`参考仓库`,count:Je.length,icon:(0,G.jsx)(se,{size:14}),tip:`拿来做参考的本机代码`}];L===`main`&&ct.push({id:`docs`,label:`文档`,count:u===null?0:u,icon:(0,G.jsx)(le,{size:14}),tip:`全部文档(含没有归属的 ref)——组的文档在右侧栏按宿主看`});let lt=L!==`main`&&B===`docs`?`repos`:B;return y===null?(0,G.jsxs)(`div`,{className:`rp-page rp-v2`,children:[(0,G.jsx)(ee,{}),(0,G.jsx)(`div`,{className:`muted`,style:{padding:20},children:`读取中…`}),s]}):(0,G.jsxs)(`div`,{className:`rp-page rp-v2`,children:[(0,G.jsxs)(`div`,{className:`page-head rp-head`,children:[(0,G.jsxs)(`div`,{className:`title-block`,children:[(0,G.jsx)(`h2`,{children:`仓库管理`}),(0,G.jsx)(Ee,{branches:Ue,value:L,onChange:e=>{z(e),U(``)},onCreate:it})]}),(0,G.jsx)(`div`,{className:`acts`,children:(0,G.jsx)(te,{kind:`repos`,titles:{add:`登记本机开发仓库`,boards:`分组管理:建组 / 成员 / 组介绍文档`,refs:`参考仓库面板:克隆 / 绑定 / 同步 / 检查 / 存储根`,transfer:`布局与仓库的导入导出(逐条选择 / 冲突方案 / 差异检查)`},actions:{add:()=>q(null),boards:()=>ue(!0),refs:()=>Y(!0),transfer:()=>be(!0)}})})]}),(0,G.jsxs)(`div`,{className:`rp-branchbar`+($?` is-group`:``),children:[(0,G.jsx)(`span`,{className:`rp-branchbar-ico`,children:$?(0,G.jsx)(ae,{size:14}):(0,G.jsx)(oe,{size:14})}),(0,G.jsx)(`span`,{className:`rp-branchbar-name`,children:$?$.name:L==="default"?`default`:`main`}),(0,G.jsx)(je,{value:H,onChange:U,count:ke?qe.length+Je.length+f:void 0}),(0,G.jsx)(`span`,{className:`rp-branchbar-acts`,children:$?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,className:`rp-branchbar-btn accent`,title:`组的文档收敛在右侧栏的文档列表里`,onClick:()=>nt($),children:[(0,G.jsx)(ce,{size:13}),` 文档 `,Number($.docCount)||0,` →`]}),(0,G.jsx)(a,{items:[{label:`添加成员`,icon:(0,G.jsx)(he,{size:13}),hint:`往这个分组里加仓库`,onPick:()=>X($.id)},{label:`刷新状态`,icon:(0,G.jsx)(fe,{size:13}),hint:`重新检查参考仓库`,onPick:()=>{j(),r(`已刷新检查结果`)}}]})]}):(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`button`,{type:`button`,className:`rp-branchbar-btn`,title:`重新检查参考仓库的状态`,onClick:()=>{j(),r(`已刷新检查结果`)},children:[(0,G.jsx)(fe,{size:13}),` 刷新状态`]})})})]}),ke?null:(0,G.jsx)(Me,{tabs:ct,value:lt,onChange:e=>V(e)}),$?(0,G.jsx)(Ie,{boards:{boards:[$],unassigned:[]},devRepos:Ve,refRepos:He,reload:P}):null,ke?(0,G.jsx)(Fe,{kw:ke,q:H,repoRows:qe,refRows:Je,docShown:f,mode:$?`group`:L==="default"?`default`:`main`,branchBoard:$,boardList:Q,repos:_,devRepos:Ve,refRepoChipsByRepo:Ge,refRepoBackLinks:Ke,checkOf:Ye,docTick:m,acts:st,onClear:()=>U(``),onDocShown:p,onDocCount:d,onSync:Ze,onOpenRepo:e=>rt(`open`,e),onOpenDocs:tt,onBindRef:e=>{me(e.key),Y(!0)},onUnbindGroup:Qe,onUnbindRepo:$e,onGoBind:(e,t)=>ot(e===`board`?`group`:`repo`,t),onManageRefs:()=>Y(!0),onAddMember:X,onGoHost:ot}):lt===`docs`?(0,G.jsx)(Pe,{repos:_,boardList:Q,q:H,tick:m,onGoHost:ot,onCount:d}):lt===`refs`?(0,G.jsx)(Ne,{rows:Je,mode:$?`group`:L==="default"?`default`:`main`,group:$,boardList:Q,refRepoBackLinks:Ke,checkOf:Ye,onSync:Ze,onOpen:e=>rt(`open`,e),onDocs:e=>tt(e),onBind:e=>{me(e.key),Y(!0)},onUnbindGroup:Qe,onUnbindRepo:$e,onGoBind:(e,t)=>ot(e===`board`?`group`:`repo`,t),onManage:()=>Y(!0)}):(0,G.jsx)(Ce,{shown:qe,devRepos:Ve,mode:$?`group`:L==="default"?`default`:`main`,filterBoard:$,refRepoChipsByRepo:Ge,acts:st,onAddMember:X}),de?(0,G.jsx)(Le,{refRepos:He,devRepos:Ve,boardList:Q,checkOf:Ye,refRepoBackLinks:Ke,refBindOpen:ge,onRefBindOpen:_e,onClose:()=>Y(!1),onSyncOne:Ze,onUnbind:Qe,onUnbindRepo:$e,onGoBind:(e,t)=>{Y(!1),setTimeout(()=>ot(e===`board`?`group`:`repo`,t),60)},onDocs:e=>tt(e),onRowAct:rt,reload:P}):null,J?(0,G.jsx)(Re,{boardList:Q,unassigned:y.unassigned,onClose:()=>ue(!1),onFilter:e=>{z(e),V(`repos`)},onMembers:X,onOpenDoc:nt,reload:P}):null,K===void 0?null:(0,G.jsx)(M,{editing:K,repos:_,onClose:()=>q(void 0),onSaved:P.all}),Xe?(0,G.jsx)(ne,{board:Xe,boards:Q,repos:_,onClose:()=>X(null),onChanged:async()=>{await Promise.all([D(),k()])}}):null,De?(0,G.jsx)(ze,{repo:De,refRepos:He,boardList:Q,currentRefs:We.get(De.key)||[],onClose:()=>Oe(null),onSaved:()=>{P.all(),h(e=>e+1)}}):null,ye?(0,G.jsx)(re,{onClose:()=>be(!1),onChanged:P.all,repos:_,boards:Q}):null,Z?(0,G.jsx)(ie,{repo:_.find(e=>e.id===Z.id)||Z,onClose:()=>xe(null),onSaved:D}):null,Se?(0,G.jsx)(Be,{repo:Se,onClose:()=>Te(null),onSaved:async()=>{await Promise.all([D(),j()])}}):null,s]})}export{Ve as default};
@@ -1 +0,0 @@
1
- import{a as e,c as t,d as n,i as r,l as i,m as a,u as o}from"./popup-D8KWI6-Q.js";import{n as s}from"./app-context-DDQnrPSP.js";import{t as c}from"./button-BEWXOABr.js";var l=a(n(),1);function u(){return i(`/api/setting`)}function d(e){return i(`/api/setting`,{method:`POST`,body:e})}function f(){return i(`/api/docs/orphans`)}function p(e={}){return i(`/api/docs/orphans/purge`,{method:`POST`,body:e})}function m(){return i(`/api/localtasks`)}function h(e){return i(`/api/localtasks/setting`,{method:`PATCH`,body:e})}function g(){return i(`/api/prompt/registry`)}function _(e){return i(`/api/localtasks/preview`,{method:`POST`,body:e})}function v(){return Promise.all([i(`/api/repos`),i(`/api/boards`)])}var y=Object.freeze([{id:`xml`,label:`XML 区块(默认)`,desc:`每段系统内容包进独立标签,agent 一眼分清任务原文与系统规则`},{id:`plain`,label:`正文直追加`,desc:`不包标签,按空行拼接(与改造前的 instruction 逐字一致)`}]);function b(e,t=``){let n=t.trim().toLowerCase(),r=new Map;for(let t of e){let e=t.key.indexOf(`[]`),i=e>=0?t.key.slice(0,e+2):``,a=e>=0?t.key.slice(e+3):t.key;if(!(!n||t.key.toLowerCase().includes(n)||String(t.label||``).toLowerCase().includes(n)||String(t.desc||``).toLowerCase().includes(n)))continue;let o=r.get(i)||[];o.push({full:t.key,rel:a,label:t.label,desc:t.desc,kind:t.kind}),r.set(i,o)}return[...r.entries()].sort(([e],[t])=>e===``?-1:t===``?1:e.localeCompare(t)).map(([e,t])=>({group:e,rows:t}))}var x=o(),S={get:`领取交付(get)`,check:`每轮检查(check)`,done:`尝试完成(done)`},C={get:`agent 执行 get 领走任务时拼在任务正文之后的一大段`,check:`每轮等待检查时告诉 agent「离目标还差多少」`,done:`agent 调 done 时给出的完成门禁`};function w(e){return S[e]||e}function T(){let e=t(),[n,r]=(0,l.useState)(null),[i,a]=(0,l.useState)({}),[o,s]=(0,l.useState)(`xml`),[u,d]=(0,l.useState)(``),[f,p]=(0,l.useState)(!1),[v,S]=(0,l.useState)(null),[T,E]=(0,l.useState)(!1),[D,O]=(0,l.useState)(``);if((0,l.useEffect)(()=>{let t=!0;return Promise.all([g(),m()]).then(([e,n])=>{if(!t)return;let i=Array.isArray(e?.plugins)?e.plugins:[];r(i),a(e?.groups||{});let o=n?.settings?.appendMode===`plain`?`plain`:`xml`;s(o);let c=e?.groups?.get?.[0]||i[0]?.id||``;d(c)}).catch(n=>t&&e(`读取失败:`+(n.message||n))),()=>{t=!1}},[e]),!n)return(0,x.jsx)(`div`,{className:`setp-note`,children:`读取提示词注册表…`});let k=n.find(e=>e.id===u)||n[0];if(!k)return(0,x.jsx)(`div`,{className:`setp-note`,children:`注册表为空:没有任何提示词插件。`});let A=Object.keys(i).length?Object.keys(i):[...new Set(n.map(e=>e.group))],j=new Map(n.map(e=>[e.id,e])),M=b(k.fields,D),N=y.find(e=>e.id===o)||y[0],P=async t=>{if(!(f||t===o)){p(!0);try{let n=await h({appendMode:t===`plain`?`plain`:`xml`});s(n?.appendMode===`plain`?`plain`:`xml`),S(null),e(`已保存追加模式(全局生效)`)}catch(t){e(String(t.message||t))}finally{p(!1)}}},F=async(t,n)=>{try{await navigator.clipboard.writeText(t),e(`已复制${n}`)}catch{e(`复制失败(剪贴板不可用)`)}},I=async()=>{if(!f){p(!0);try{let e=await _({id:0,text:`(预览草稿)这是一条用于查看提示词渲染效果的任务`,summary:``});S({instruction:String(e?.instruction||``),segments:Array.isArray(e?.segments)?e.segments:[],at:new Date().toLocaleTimeString(`zh-CN`,{hour12:!1})}),E(!0)}catch(t){e(String(t.message||t))}finally{p(!1)}}};return(0,x.jsxs)(`div`,{className:`setp-tpl-editor`,children:[(0,x.jsxs)(`div`,{className:`setp-tpl-head`,children:[(0,x.jsx)(`span`,{className:`setp-tpl-head-label`,children:`系统提示词追加方式`}),(0,x.jsx)(`div`,{className:`setp-seg`,role:`group`,"aria-label":`系统提示词追加方式`,children:y.map(e=>(0,x.jsx)(`button`,{type:`button`,className:`setp-seg-btn`+(o===e.id?` is-on`:``),"aria-pressed":o===e.id,title:e.desc,disabled:f,onClick:()=>void P(e.id),children:e.label},e.id))}),(0,x.jsx)(`span`,{className:`setp-note`,children:N.desc})]}),(0,x.jsxs)(`div`,{className:`ppt-split`,children:[(0,x.jsxs)(`div`,{className:`ppt-rail`,children:[(0,x.jsxs)(`div`,{className:`ppt-rail-head`,children:[(0,x.jsx)(`b`,{children:`时机 / 段落`}),(0,x.jsxs)(`span`,{className:`setp-note`,children:[`共 `,n.length,` 段`]})]}),(0,x.jsx)(`div`,{className:`ppt-rail-list`,children:A.map(e=>{let t=i[e]||n.filter(t=>t.group===e).map(e=>e.id);return(0,x.jsxs)(`div`,{className:`ppt-grp`,children:[(0,x.jsx)(`div`,{className:`ppt-grp-head`,title:C[e]||``,children:w(e)}),t.map((e,t)=>{let n=j.get(e);return n?(0,x.jsxs)(`div`,{className:`ppt-rail-row`+(n.id===k.id?` is-on`:``),role:`button`,tabIndex:0,onClick:()=>d(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),d(e))},children:[(0,x.jsx)(`span`,{className:`ppt-rail-pos`,children:t+1}),(0,x.jsxs)(`span`,{className:`ppt-rail-main`,children:[(0,x.jsx)(`span`,{className:`ppt-rail-label`,children:n.label}),(0,x.jsx)(`span`,{className:`ppt-rail-active`,children:n.id})]})]},e):null})]},e)})})]}),(0,x.jsxs)(`div`,{className:`ppt-ed`,children:[(0,x.jsxs)(`div`,{className:`ppt-ed-head`,children:[(0,x.jsxs)(`div`,{className:`ppt-ed-title`,children:[(0,x.jsx)(`b`,{children:k.label}),(0,x.jsx)(`code`,{className:`ppt-ed-tag`,children:k.tag}),(0,x.jsxs)(`span`,{className:`ppt-pill is-write`,title:`本段渲染时的数据域:${k.varScope.join(` / `)}(seed + 本段自己产的数据;不含别的段)`,children:[`数据域 `,k.varScope.filter(e=>![`task`,`cwd`,`goal`,`source`,`summary`,`name`,`params`].includes(e)).join(` · `)||`仅任务上下文`]}),(0,x.jsxs)(`span`,{className:`ppt-pill`,children:[w(k.group),` · 第 `,k.order,` 位`]})]}),(0,x.jsxs)(`span`,{className:`ppt-ed-sub`,children:[C[k.group]||``,` · 本段的模板只能引用自己的变量与任务上下文,别的段的数据引用不到`]})]}),(0,x.jsxs)(`div`,{className:`ppt-ro-note`,children:[`正文是插件类里的内置模板(`,(0,x.jsx)(`code`,{children:`modules/promptplug/plugins`}),`),不再存库、不可在此编辑; 改文案请改代码。`]}),(0,x.jsx)(`textarea`,{className:`ppt-tpl-area`,value:k.template,readOnly:!0,spellCheck:!1,"aria-label":`${k.label} 的内置模板`}),k.fields.length>0&&(0,x.jsxs)(`div`,{className:`ppt-vars`,"aria-label":`该段可用变量`,children:[(0,x.jsxs)(`div`,{className:`ppt-vars-head`,children:[(0,x.jsxs)(`span`,{className:`ppt-vars-cap`,children:[`可用变量(`,k.fields.length,`)`]}),(0,x.jsx)(`input`,{className:`ppt-vars-q`,value:D,placeholder:`过滤变量,如 localPath`,"aria-label":`过滤变量`,onChange:e=>O(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`ppt-vars-body`,children:[M.map(e=>(0,x.jsxs)(`div`,{className:`ppt-vars-grp`,children:[e.group&&(0,x.jsxs)(`div`,{className:`ppt-vars-grp-head`,title:`在 {{#each ${e.group.slice(0,-2)}}} 内部写相对名`,children:[e.group,` 内部(each 里写相对名,共 `,e.rows.length,`)`]}),(0,x.jsx)(`div`,{className:`ppt-vars-chips`,children:e.rows.map(e=>(0,x.jsxs)(`code`,{className:`ppt-var`,"aria-disabled":`true`,title:`${e.full}${e.desc?` —— ${e.desc}`:``}`,children:[(0,x.jsx)(`span`,{className:`ppt-var-key`,children:e.rel}),e.label&&e.label!==e.full&&e.label!==e.rel&&(0,x.jsx)(`span`,{className:`ppt-var-desc`,children:e.label})]},e.full))})]},e.group||`_main`)),M.length===0&&(0,x.jsxs)(`span`,{className:`ppt-vars-cap`,children:[`没有匹配「`,D,`」的变量`]})]})]}),(0,x.jsxs)(`div`,{className:`ppt-actions`,children:[(0,x.jsx)(c,{variant:`secondary`,disabled:f,onClick:()=>void F(k.template,`模板正文`),children:`复制正文`}),(0,x.jsx)(`span`,{className:`spacer`}),(0,x.jsx)(c,{variant:`secondary`,className:`ppt-preview-btn`,disabled:f,title:`用一条草稿任务渲染当前内置模板的实际输出`,onClick:()=>void I(),children:`预览交付`})]}),(0,x.jsxs)(`div`,{className:`ppt-pv`,children:[(0,x.jsxs)(`button`,{type:`button`,className:`ppt-pv-head`,"aria-expanded":T,onClick:()=>E(e=>!e),children:[(0,x.jsx)(`b`,{children:`交付预览`}),(0,x.jsx)(`span`,{className:`setp-note`,children:v?`命中 ${v.segments.length}/${n.length} 段 · ${v.at} 渲染`:`尚未渲染 · 按内置模板合成`}),(0,x.jsx)(`span`,{className:`ppt-pv-toggle`,children:T?`收起 ⌃`:`展开 ⌄`})]}),T&&(0,x.jsx)(`div`,{className:`ppt-pv-body`,children:v?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`pre`,{className:`ppt-pv-pre`,children:v.instruction||`(本次领取没有可输出的段落)`}),v.segments.length>0&&(0,x.jsx)(`div`,{className:`ppt-pv-segs`,children:v.segments.map((e,t)=>(0,x.jsx)(`span`,{className:`ppt-pv-seg`,children:(0,x.jsx)(`span`,{className:`ppt-pv-seg-label`,children:e.label})},`${e.id}-${t}`))})]}):(0,x.jsx)(`div`,{className:`ppt-pv-empty`,children:`点右上「预览交付」,用一条草稿任务渲染真实领取时会拿到的提示词。`})})]})]})]})]})}function E(){let e=t(),n=s(),r=n.patchPrefs,[i,a]=(0,l.useState)([]),[o,c]=(0,l.useState)([]),[u,d]=(0,l.useState)([]),f=(0,l.useCallback)(()=>{v().then(([e,t])=>{a(Array.isArray(e)?e:e?.repos||[]),c(Array.isArray(t)?t:t?.boards||[]),d(n.prefs?.hidden||[])}).catch(t=>e(`读取失败:`+(t.message||t)))},[e,n.prefs]);(0,l.useEffect)(()=>{f()},[f]);let p=e=>{let t=n.prefs?.hidden||[],i=t.includes(e)?t.filter(t=>t!==e):[...t,e];r&&r({hidden:i}),d(i)},m=(e,t,n,r)=>(0,x.jsx)(`div`,{className:`setp-row`,children:(0,x.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`},children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:!u.includes(t),onChange:()=>p(t)}),(0,x.jsx)(`span`,{children:n}),r?(0,x.jsx)(`span`,{className:`mono faint`,children:r}):null]})},e+`:`+t);return(0,x.jsxs)(`div`,{className:`setp-side`,children:[(0,x.jsx)(`div`,{className:`setp-note`,children:`勾掉的项目组 / 项目不在侧边栏显示(登记与数据都留着,随时勾回来)。`}),(0,x.jsx)(`div`,{className:`setp-row`,children:(0,x.jsx)(`span`,{children:`项目组(指针)`})}),o.map(e=>m(`board`,e.key||e.id,e.name,`${(e.repos||[]).length} 个模块`)),!o.length&&(0,x.jsx)(`div`,{className:`setp-note`,children:`还没有项目组。`}),(0,x.jsx)(`div`,{className:`setp-row`,children:(0,x.jsx)(`span`,{children:`项目 / 仓库(模块)`})}),i.map(e=>m(`repo`,e.key||e.id,e.name,e.path)),!i.length&&(0,x.jsx)(`div`,{className:`setp-note`,children:`还没有登记仓库。`})]})}var D=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`storage`,label:`本机存储`,icon:`archive`},{id:`docsCleanup`,label:`文档清理`,icon:`archive`},{id:`prompts`,label:`提示词模板`,icon:`flow`},{id:`sidebar`,label:`侧栏显示`,icon:`sidebar`}];function O(e){if(!e)return`—`;let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function k(){let n=s(),i=t(),{dialog:a,node:o}=r(),m=n.prefs,h=n.patchPrefs||(()=>{}),[g,_]=(0,l.useState)(`pref`),[v,y]=(0,l.useState)(null),[b,S]=(0,l.useState)(!1),[C,w]=(0,l.useState)(null),[k,A]=(0,l.useState)(!1),j=(0,l.useCallback)(async()=>{try{y(await u())}catch(e){i(`读取设置失败:`+(e.message||e))}},[i]),M=(0,l.useCallback)(async()=>{try{w(await f())}catch(e){i(`读取孤儿文档失败:`+(e.message||e))}},[i]);(0,l.useEffect)(()=>{j()},[j]),(0,l.useEffect)(()=>{g===`docsCleanup`&&M()},[g,M]);let N=e=>e().catch(e=>i(String(e.message||e))),P=e=>N(async()=>{if(!e||await a({title:`立即清理孤儿文档`,message:`软删所有「到期 + 没有正文」的孤儿文档;有正文的只列清单,不会自动删。继续?`,okText:`清理`})){A(!0);try{let t=await p({apply:e});w(t),i(e?`已清理 ${t.deleted?.length??0} 篇孤儿文档`:`预演:将清理 ${t.eligible?.length??0} 篇孤儿文档(未删除)`)}finally{A(!1)}}}),F=e=>N(async()=>{S(!0);try{y(await d(e)),i(`已保存`)}finally{S(!1)}}),I={pref:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`setp-row`,children:[(0,x.jsx)(`span`,{children:`侧边栏默认收起`}),(0,x.jsxs)(`button`,{className:`toggle`+(m?.defaultFolded?` on`:``),onClick:()=>h({defaultFolded:!m?.defaultFolded}),children:[(0,x.jsx)(`span`,{className:`dot`}),m?.defaultFolded?`开`:`关`]})]}),(m?.hidden||[]).length>0&&(0,x.jsxs)(`div`,{className:`setp-row`,children:[(0,x.jsxs)(`span`,{children:[`隐藏仓库 `,m?.hidden?.length,` 个`]}),(0,x.jsx)(c,{variant:`secondary`,onClick:()=>h({hidden:[]}),children:`恢复显示`})]})]}),work:(0,x.jsx)(x.Fragment,{children:(0,x.jsxs)(`div`,{className:`setp-row`,children:[(0,x.jsx)(`span`,{children:`布局`}),(0,x.jsx)(c,{variant:`secondary`,onClick:async()=>{await a({title:`重置为初始两栏`,message:`丢掉存下来的布局,回到初始的两栏(目录 + 开始)?`,okText:`重置`})&&n.shell&&n.shell.resetLayout()},children:`重置为初始两栏`})]})}),storage:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`setp-row`,children:[(0,x.jsx)(`span`,{children:`参考仓库存储根`}),(0,x.jsxs)(`span`,{className:`setp-input`,children:[(0,x.jsx)(`input`,{value:v&&v.gitRepoRoot||``,placeholder:`(未设置 —— clone 参考仓库前先设)`,onChange:e=>y(t=>({...t||{},gitRepoRoot:e.target.value}))}),(0,x.jsx)(c,{variant:`secondary`,disabled:!v||b,onClick:()=>v&&F({gitRepoRoot:v.gitRepoRoot}),children:`保存`})]})]}),(0,x.jsxs)(`div`,{className:`setp-row`,children:[(0,x.jsx)(`span`,{children:`开发仓库克隆根`}),(0,x.jsxs)(`span`,{className:`setp-input`,children:[(0,x.jsx)(`input`,{value:v&&v.gitDevRoot||``,placeholder:`(未设置 —— 导入布局时只登记不克隆)`,onChange:e=>y(t=>({...t||{},gitDevRoot:e.target.value}))}),(0,x.jsx)(c,{variant:`secondary`,disabled:!v||b,onClick:()=>v&&F({gitDevRoot:v.gitDevRoot}),children:`保存`})]})]})]}),docsCleanup:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`setp-row`,children:[(0,x.jsx)(`span`,{children:`孤儿保留天数`}),(0,x.jsxs)(`span`,{className:`setp-input`,children:[(0,x.jsx)(`input`,{type:`number`,min:1,max:3650,value:v?v.orphanTtlDays??3:3,onChange:e=>y(t=>({...t||{},orphanTtlDays:Number(e.target.value)}))}),(0,x.jsx)(c,{variant:`secondary`,disabled:!v||b,onClick:()=>v&&F({orphanTtlDays:v.orphanTtlDays}),children:`保存`})]})]}),(0,x.jsx)(`div`,{className:`setp-note`,children:`孤儿 = 没有任何 ref_bindings 归属的 ref。到期后软删(ref_bodies 保留);有正文的到期孤儿不自动删,需人工处置。`}),(0,x.jsxs)(`div`,{className:`setp-row`,children:[(0,x.jsx)(`span`,{children:C?`孤儿 ${C.total} 篇 · 到期 ${C.due}(空壳 ${C.dueEmpty} / 有正文 ${C.dueWithBody})`+(C.dueSoon?` · 24h 内到期 ${C.dueSoon}`:``)+(C.untimed?` · 未计时 ${C.untimed}`:``):`孤儿清单:读取中…`}),(0,x.jsxs)(`span`,{className:`setp-gc-actions`,children:[(0,x.jsx)(c,{variant:`secondary`,onClick:()=>void M(),children:`刷新`}),(0,x.jsx)(c,{variant:`secondary`,disabled:k,onClick:()=>void P(!1),children:`预演清理`}),(0,x.jsx)(c,{variant:`secondary`,disabled:k,onClick:()=>void P(!0),children:`立即清理`})]})]}),(0,x.jsxs)(`div`,{className:`setp-gc-list`,children:[(C?.orphans||[]).map(e=>(0,x.jsxs)(`div`,{className:`setp-gc-item`+(e.due?` is-due`:``),children:[(0,x.jsxs)(`div`,{className:`setp-gc-main`,children:[(0,x.jsx)(`b`,{children:e.desc||e.refId}),(0,x.jsx)(`span`,{className:`setp-badge`+(e.hasBody?` soft`:``),children:e.hasBody?`有正文 ${e.bodyBytes}B`:`空壳`}),e.due&&(0,x.jsx)(`span`,{className:`setp-badge is-due`,children:`已到期`})]}),(0,x.jsxs)(`div`,{className:`setp-gc-meta`,children:[(0,x.jsx)(`code`,{children:e.refId}),(0,x.jsxs)(`span`,{children:[`失绑 `,O(e.unboundAt)]}),(0,x.jsx)(`span`,{children:e.unboundAt?`剩余 ${e.remainingDays} 天`:`未计时(维护时起算)`}),e.origin===`external`&&e.locator&&(0,x.jsx)(`span`,{className:`setp-gc-path`,children:e.locator})]})]},e.refId)),C&&C.orphans.length===0&&(0,x.jsx)(`div`,{className:`setp-note`,children:`(当前没有孤儿文档)`}),!C&&(0,x.jsx)(`div`,{className:`setp-note`,children:`(点「刷新」读取)`})]}),(C?.recentDeletions||[]).length>0&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`setp-h`,children:`最近清理`}),(0,x.jsx)(`div`,{className:`setp-gc-list`,children:(C?.recentDeletions||[]).map(e=>(0,x.jsxs)(`div`,{className:`setp-gc-log`,children:[O(e.deletedAt),` · `,(0,x.jsx)(`code`,{children:e.refId}),` · `,e.reason,` · TTL `,e.ttlDays,` 天`,e.desc?` · ${e.desc}`:``]},e.refId+`@`+e.deletedAt))})]})]}),prompts:(0,x.jsx)(T,{}),sidebar:(0,x.jsx)(E,{})};return(0,x.jsxs)(`div`,{className:`setp`,children:[(0,x.jsx)(`nav`,{className:`setp-nav`,"aria-label":`设置分区`,children:D.map(t=>(0,x.jsxs)(`button`,{className:`setp-navitem`+(g===t.id?` on`:``),"aria-current":g===t.id,onClick:()=>_(t.id),children:[(0,x.jsx)(e,{name:t.icon,size:14}),(0,x.jsx)(`span`,{children:t.label})]},t.id))}),(0,x.jsxs)(`div`,{className:`setp-body`,children:[(0,x.jsx)(`div`,{className:`setp-h`,children:D.find(e=>e.id===g)?.label}),I[g]]}),o]})}export{k as default};
@@ -1,11 +0,0 @@
1
- import{a as e,c as t,d as n,i as r,m as i,t as a,u as o}from"./popup-D8KWI6-Q.js";import{r as s,t as c,v as l}from"./workspace-D3jbcTwf.js";import{n as u}from"./app-context-DDQnrPSP.js";import{A as d,a as f,c as p,d as m,i as h,l as g,m as _,n as v,o as y,r as b,s as x,t as S}from"./md-history-CZUF_FhN.js";import{n as C,r as w,t as T}from"./frontmatter-CN6IlxWU.js";import{t as E}from"./status-tag-BD_0iWMB.js";import{r as ee,t as D}from"./md-parse-C9Vd6ejP.js";import{i as O,r as te,t as k}from"./use-rail-drag-ufwy2XZB.js";import{t as A}from"./board-view-BVennxTs.js";import{t as j}from"./route-crumb-BcDPd7Ht.js";import{c as M,d as N,f as P,l as ne,m as re,o as F,p as I,s as ie,u as L}from"./index-CMjG5NVU.js";import{a as R,i as z,n as ae,o as B}from"./composer-launch-DRi9mZE1.js";import{C as oe,T as V,_ as H,a as U,b as se,c as W,d as ce,f as le,g as G,h as ue,l as K,m as de,n as fe,o as pe,p as me,r as q,s as he,t as ge,v as _e,x as ve,y as ye}from"./task-utils-bJH1-Cjy.js";import{a as be}from"./fill-session-fHxQHFaD.js";import{t as xe}from"./new-task-from-template-DDWu4yR4.js";import{n as Se}from"./task-intent-CX5DZccN.js";var J=i(n(),1),Ce=/^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/,we=/完成总结/,Te=/反馈/,Ee=/第\s*(\d+)\s*轮/;function De(e){let t=String(e??``).split(`
2
- `),n=t[0],r=n?n.match(Ce):null;if(!r)return null;let i=t.slice(1).map(e=>e.replace(/^>[ \t]?/,``)).filter(e=>e.trim()!==``).join(`
3
- `);return{title:String(r[1]??``).trim(),body:i}}function Oe(e){let t=x(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim(),o=De(a);if(o&&we.test(o.title)){let e=Number((o.title.match(Ee)||[])[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&&Te.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
- `:``)+a:r.feedbackText+=(r.feedbackText?`
5
- `:``)+a)}),n.filter(e=>e.ackText!==``)}function ke(e){let t=String(e?.ackText||``).split(`
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??1} 轮 · ${n}`}var Y=o();function Ae(e,t,n){return!e||t<0?null:e.querySelector(`.mdw-lp-block[data-i="${t}"]`)||[...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)[n]||null}function je({nodes:e=[],scrollRoot:t=null,onJump:n=null}){let[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(0),{railRef:s,pos:c,dragging:l,draggedRef:u,handleProps:d}=k(),f=(0,J.useMemo)(()=>(e||[]).map(e=>({...e,title:ke(e)})),[e]);(0,J.useEffect)(()=>{let e=t;if(!e||!f.length)return;let n=()=>{let t=e.getBoundingClientRect(),n=0;for(let r of f){let i=Ae(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,f]);let p=(0,J.useCallback)(e=>{let r=t,i=r?Ae(r,e.blockIndex,e.round-1):null;i&&(i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e.round)),n?.(e)},[t,n]);return f.length?(0,Y.jsxs)(`aside`,{ref:s,className:`doc-rail ack-rail`+(r?` open`:``)+(l?` dragging`:``),style:c?{left:c.x,top:c.y,right:`auto`,bottom:`auto`}:void 0,"aria-label":`验收轮次`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:r?`收起轮次(双击回默认位)`:`展开轮次 · 按住拖动 · 双击回默认位`,"aria-expanded":r,onClick:()=>{if(u.current){u.current=!1;return}i(e=>!e)},...d,children:[(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{}),(0,Y.jsx)(`span`,{})]}),(0,Y.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`验收轮次`,children:f.map(e=>(0,Y.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:()=>p(e)},e.round))}),r&&(0,Y.jsx)(`div`,{className:`doc-rail-panel`,children:(0,Y.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,Y.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`验收轮次`}),f.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(a===e.round?` on`:``),title:e.ackText,onClick:()=>p(e),children:[`第 `,e.round,` 轮`]},e.round))]})})]}):null}var Me=[{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 Ne({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,Y.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,Y.jsxs)(`div`,{className:`mdw-sel-fmt`,role:`group`,"aria-label":`选区格式`,children:[Me.map(e=>(0,Y.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn ${e.cls}`,title:e.title,onClick:()=>t?.(e.op),children:e.label},e.op)),(0,Y.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn`,title:`复制`,onClick:n,children:`复制`}),(0,Y.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn comment`,title:`评论 → 打开 md 编辑面板`,onClick:()=>r?.(),children:`评论`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`cap`,children:`选区`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r?.(),children:`评论`}),(0,Y.jsx)(`div`,{className:`sep`}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,children:`复制选区`}),i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`sep`}),(0,Y.jsx)(`button`,{type:`button`,className:`danger`,title:`删除选区触到的整段块`,onClick:i,children:`删除选区`})]}):null]})})}var Pe=[{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 Fe({onClose:e}){return(0,Y.jsx)(a,{title:`快捷键`,onClose:e,size:`lg`,className:`mdw-sheet`,children:(0,Y.jsx)(`div`,{className:`mdw-sheet-cols`,children:Pe.map(e=>(0,Y.jsxs)(`section`,{className:e.title===`导航与文件`?`wide`:void 0,children:[(0,Y.jsx)(`h4`,{children:e.title}),(0,Y.jsx)(`dl`,{children:e.items.map(([e,t])=>(0,Y.jsxs)(`div`,{className:`mdw-sheet-row`,children:[(0,Y.jsx)(`dt`,{children:(0,Y.jsx)(`kbd`,{children:e})}),(0,Y.jsx)(`dd`,{children:t})]},e))})]},e.title))})})}var X={origin:`起点`,reopen:`反馈`,comment:`评论`,current:`当前`};function Ie({nodes:e=[],onOpenNode:t}){return e.length?(0,Y.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=X[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,Y.jsxs)(`li`,{className:`mdw-chain-li${n.current?` is-current`:``}`,children:[(0,Y.jsxs)(`div`,{className:`mdw-chain-rail`,"aria-hidden":!0,children:[(0,Y.jsx)(`span`,{className:`mdw-chain-dot`}),r<e.length-1?(0,Y.jsx)(`span`,{className:`mdw-chain-line`}):null]}),(0,Y.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,Y.jsx)(`span`,{className:`mdw-chain-kind`,children:a}),(0,Y.jsx)(`span`,{className:`mdw-chain-ex`,children:o||`—`}),s?(0,Y.jsx)(`span`,{className:`mdw-chain-meta`,children:s}):null]})]},i)})}):(0,Y.jsx)(`div`,{className:`mdw-chain-empty muted`,children:`这条任务还没有链(反馈 / 评论派生后会出现)`})}function Le({open:e,nodes:t,onOpenNode:n,onClose:r}){return e?(0,Y.jsxs)(a,{title:`任务链`,onClose:r,size:`md`,className:`mdw-chain-modal`,children:[(0,Y.jsx)(`p`,{className:`mdw-chain-hint`,children:`从早到晚排列。点非当前节点可在旁路打开内容。`}),(0,Y.jsx)(Ie,{nodes:t,onOpenNode:e=>{n?.(e),r?.()}})]}):null}function Re({id:e,isDraft:t,topicKey:n,task:r,taskRow:i}){let[a,o]=(0,J.useState)(null);(0,J.useEffect)(()=>{o(null)},[e]);let s=i?.timegoal||null,c=a||{duration:s?.duration||``,prompt:s?.prompt||``},l=t||!!i&&i.status===`pending`,u=t||!!i&&i.status!==`done`&&i.status!==`cancelled`&&(i.status===`pending`||!!s),d=!t&&!!s&&r!=null,[f,p]=(0,J.useState)({busy:!1,error:``,data:null}),m=(0,J.useCallback)(()=>{if(t||!n||r==null)return;p(e=>({...e,busy:!0,error:``}));let e=new URLSearchParams({id:String(r),key:String(n)});ue(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,r]);return(0,J.useEffect)(()=>{d&&m()},[d,m]),{goalDraft:a,setGoalDraft:o,goal:c,goalEditable:l,goalPromptEditable:u,declaredGoal:s,goalLog:f,loadGoalLog:m,canShowGoalLog:d}}function ze({isDraft:e,task:t,taskRow:n,topicKey:r,topic:i,isGlobal:a,groupAnchored:o,groupId:s,app:l,model:u,historyId:d,toast:f}){let[p,m]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(e||t==null||/^draft/i.test(String(t))){m(null);return}let n=!1,r=a?`key=${encodeURIComponent(A)}&id=${Number(t)}`:`cwd=${encodeURIComponent(i?.cwd||``)}&id=${Number(t)}`;return _e(r).then(e=>{n||m(e)}).catch(()=>{n||m(null)}),()=>{n=!0}},[e,t,a,i?.cwd,n?.history?.length,n?.forkOf,n?.reopenCount]);let h=(0,J.useMemo)(()=>{if(e||!n)return[];let i=(String(n.text||``).split(`
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:i,attachmentCount:0,current:!0}),e}let o=Array.isArray(p?.ancestors)?[...p.ancestors].reverse():[],s=Array.isArray(p?.children)?p.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:i,attachmentCount:0,current:!0,taskId:Number(t),dirKey:r||`__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,p,t,r]),g=(0,J.useMemo)(()=>{if(d==null||!n)return null;let e=Number(d);return(n.history||[]).find(t=>Number(t.id)===e)||null},[d,n]),_=Array.isArray(p?.children)?p.children:[],v=_.length===0,y=_.length?_[_.length-1]??null:null;return{chainApi:p,chainNodes:h,historyNode:g,chainChildren:_,isChainTip:v,latestChild:y,openLatestRound:(0,J.useCallback)(()=>{y&&l.openPage&&(o?l.openPage({groupId:s,task:String(y.id),name:`#${y.id}`}):l.openPage({dirKey:String(y.key||r||`__GLOBAL__`),task:String(y.id),name:`#${y.id}`}))},[y,l.openPage,o,s,r]),openHistoryBeside:(0,J.useCallback)(n=>{let i=u||l.model;if(i&&!e){if(n?.current){f(`当前节点就是本页`);return}if(n?.historyId!=null){c(i,{component:`page`,name:`链 #${t} · ${n.kind||n.historyId}`,config:{dirKey:r||`__GLOBAL__`,task:String(t),historyId:Number(n.historyId)}});return}if(n?.taskId!=null&&n?.dirKey){c(i,{component:`page`,name:n.excerpt?String(n.excerpt).slice(0,24):`#${n.taskId}`,config:{dirKey:String(n.dirKey),task:String(n.taskId)}});return}f(`这个节点没有可打开的内容`)}},[u,l.model,e,r,t,f])}}function Be({id:e}){let[t,n]=(0,J.useState)(null),r=(0,J.useRef)(``);return(0,J.useEffect)(()=>{n(null),r.current=``},[e]),(0,J.useEffect)(()=>{let e=()=>n(null);return document.addEventListener(`scroll`,e,!0),()=>document.removeEventListener(`scroll`,e,!0)},[]),{selMenu:t,setSelMenu:n,lastSel:r,placeSelMenu:(0,J.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,J.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,J.useCallback)(()=>{n(null),r.current=``},[])}}function Ve({id:e,taskRow:t,dockTab:n,dockOpen:r}){let[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(!1),c=(0,J.useRef)(null),l=String(t?.roundSummary||``).length>140;return(0,J.useEffect)(()=>{a(!1),s(!1)},[e,t?.roundSummary]),(0,J.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 He({doc:e,id:n,isDraft:r,task:i,taskRow:a,topicKey:o,topic:c,isGlobal:u,boardCtx:d,docFm:f,groupAnchored:m,groupId:h,rows:g,app:_,model:v,tabId:b,tpl:x,refreshLocal:E,markDirty:O,histRef:te,editorApiRef:k,attachAreaRef:j,setDirty:M,goal:re,goalEditable:ie,goalPromptEditable:ae,declaredGoal:B,guard:H,dialog:U,showDockTab:se}){let W=t(),G=(0,J.useCallback)((e,t)=>{let n=(e||``).trim()||`未命名任务`,r=T(t),i=Object.keys(r).length>0,a=C(t);return a=p(a),a=/^#\s+/m.test(a)?a.replace(/^#\s+.+$/m,`# ${n}`):`# ${n}\n\n${a}`,i?w(a,r):a},[]),ue=(0,J.useCallback)(()=>{let e=(re.duration||``).trim(),t=(re.prompt||``).trim();if(t&&!e)return{error:`时间目标要填时长(如 2h / 90m);只写附加要求无效`};if(!r){let n=B?.duration||``,r=B?.prompt||``,i=e!==n;return!i&&t===r?{}:i?ie?e?{duration:e,goalPrompt:t}:{clearGoal:!0}:{error:`已领取计时,时长不可改(附加要求仍可直接改)`}:ae?{goalPrompt:t}:{}}return e?{duration:e,goalPrompt:t}:{}},[re,ie,ae,r,B]),fe=(0,J.useCallback)(()=>H(async()=>{if(!e)return;let t=(e.title||``).trim()||`未命名任务`,a=T(e.body),s=G(t,e.body),f=a.project?g.find(e=>!e.isGlobal&&e.repo&&e.repo.key===a.project):null,p=!!(d&&a.project&&d.members.some(e=>e.key===a.project)),y=ue();if(y.error){W(y.error);return}if(!r){let r=await ye({cwd:u?f?f.cwd:void 0:c?.cwd,key:u&&!f?A:void 0,id:Number(i),text:s,...y});if(r?.moved){let a=r.key||o,c=String(r.task?.id??i),u=F(I(a),c);R(c,e.attachments),N(n,u,{title:t,body:r.task?.text||s}),v&&b&&v.doAction(l.updateNodeAttributes(b,{config:m?{groupId:h,task:c}:{dirKey:a,task:c}})),_.onNavigate&&_.onNavigate(m?`#/group/${encodeURIComponent(h||``)}?task=${encodeURIComponent(c)}`:`#/dir/${encodeURIComponent(a||``)}?task=${encodeURIComponent(c)}`),M(!1),S(te.current,u),W(`已改归属项目:任务迁到「${r.name}」#${c}`),E?.();return}R(i,e.attachments),P(n,{title:t,body:s}),M(!1),S(te.current,n),W(y.clearGoal?`已同步 MD · 时间目标已清除`:y.duration?`已同步 MD · 时间目标已更新`:`已同步 MD`),E?.();return}let x=await K({...p?{text:s,board:d.board.id,project:a.project}:a.project?{text:s,project:a.project}:u?{global:!0,text:s}:{cwd:c?.cwd,text:s},...y}),C=x?.task?.id??x?.id;if(C!=null){let r=x?.key||o,i=I(r);R(C,e.attachments);let a=F(i,String(C));N(n,a,{title:t,body:s}),v&&b&&v.doAction(l.updateNodeAttributes(b,{config:m?{groupId:h,task:String(C)}:{dirKey:r,task:String(C)}})),_.onNavigate&&_.onNavigate(m?`#/group/${encodeURIComponent(h||``)}?task=${encodeURIComponent(String(C))}`:`#/dir/${encodeURIComponent(r||``)}?task=${encodeURIComponent(String(C))}`),M(!1),S(te.current,a)}W(`已提交:${D(t)}`),E?.()}),[e,n,r,i,o,c,u,d,m,h,g,_,v,b,E,te,M,G,ue,H,W]),pe=(0,J.useCallback)(async e=>{let t=await e.text(),n=e.name.replace(/\.md$/i,``);await H(async()=>{let r=t.startsWith(`#`)?t:`# ${n}\n\n${t}`,i=await K(u?{global:!0,text:r}:{cwd:c?.cwd,text:r});W(`已导入:${e.name}`),E?.();let a=i?.task?.id??i?.id;a!=null&&_.openPage&&(m?_.openPage({groupId:h,task:String(a),name:`#${a}`}):_.openPage({dirKey:o,task:String(a),name:`#${a}`}))})},[u,m,f.project,c?.cwd,o,h,_,E,H,W]),me=(0,J.useCallback)(async()=>{if(!e||r)return;let t=e.title||`#${i}`;await U({title:`删除任务「${t}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&H(async()=>{await oe(u?{key:A,id:Number(i)}:{cwd:c?.cwd,id:Number(i)}),W(`已删除「${t}」`);let e=b&&(v||_.model||null)?.getNodeById?.(b),n=e&&e.getConfig&&e.getConfig()||{};typeof e?.getWindowId==`function`&&e.getWindowId()===`float`||n.beside||!_.onNavigate?v&&b&&v.doAction(l.deleteTab(b)):m?_.onNavigate(`#/group/`+encodeURIComponent(h||``)):u?_.onNavigate(`#/global`):_.onNavigate(`#/dir/`+encodeURIComponent(o||``)),E?.()})},[e,r,i,u,c,v,b,_,m,h,o,E,H,W,U]),q=String(a?.status??``),he=!r&&!!a&&(q===`pending`||q===`claimed`),ge=!r&&!!a&&q===`pending`,_e=he||ge,ve=(0,J.useCallback)(t=>{(t===`done`?!he:!ge)||H(async()=>{let n=e?.title||`#${i}`,r=u?{key:A}:{cwd:c?.cwd};if(t===`done`){let e=q===`claimed`,t=String(a?.claimedByName||a?.claimedBy||``).trim(),o=await U({title:`标为完成「${n}」`,message:e?`该任务正被${t?` ${t} `:` agent `}领取中。你是最终验收方——确认它已经做完、直接标为完成?可写一句完成总结(agent 稍后的回执会被忽略,不算冲突)。`:`任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。`,input:!0,placeholder:`完成总结(可选;留空使用默认说明)`,okText:`标为完成`});if(o==null)return;await le({...r,ids:[Number(i)],status:`done`,summary:String(o).trim()}),W(`已标为完成 #${i}`)}else{if(!await U({title:`取消任务「${n}」`,message:`只处理待领取任务。取消为终态,原文留档。`,danger:!0,okText:`取消任务`}))return;await le({...r,ids:[Number(i)],status:`cancelled`}),W(`已取消 #${i}`)}E?.()})},[he,ge,e,i,u,c,q,a,E,H,W,U]),Se=!r&&!!a&&(q===`pending`||q===`plan`);return{composeText:G,goalPatchOf:ue,submit:fe,importMd:pe,delTask:me,canComplete:he,canCancel:ge,canCloseTask:_e,closeTask:ve,canPlan:Se,togglePlan:(0,J.useCallback)(()=>{if(!Se)return;let e=q===`plan`?`pending`:`plan`;H(async()=>{let t=u?{key:A}:{cwd:c?.cwd};await V({...t,id:Number(i),to:e}),W(e===`plan`?`已把 #${i} 转成草稿态(不进队列)`:`已把 #${i} 转回待领取`),E?.()})},[Se,q,i,u,c,H,W,E]),addFiles:(0,J.useCallback)(async(t,a={})=>{if(!e)return;let{items:o,imageInserts:s,fileInserts:l}=await z(t),d=L(n)||e,f=d.body||``,p=s.join(``),m=f,h=null;if(p){let e=y(f,p,a);m=e.body,h=e.insertAt+p.length}l.length&&(m=y(m,l.join(``),{}).body);let g={};if(m!==f&&(g.body=m),o.length&&(g.attachments=[...d.attachments||[],...o]),Object.keys(g).length){if(P(n,g),a.mode===`edit`&&h!=null&&requestAnimationFrame(()=>{k.current?.focus?.();let e=document.querySelector(`.mdw-editor`);if(e)try{e.setSelectionRange(h,h)}catch{}}),!r){g.attachments&&R(i,g.attachments);let e=G(d.title,g.body||m);P(n,{body:e,title:ee(e)});try{await ye({cwd:u?void 0:c?.cwd,key:u?A:void 0,id:Number(i),text:e}),M(!1),E?.(),W(o.length?`已添加附件并同步(${o.length})`:`已同步附件`)}catch(e){O(),W(`附件已插入,同步失败:${e.message||e}`)}return}O()}},[e,n,r,i,c,u,M,E,O,G,k,W]),newTask:(0,J.useCallback)(()=>{let e=(x?.templates||[]).find(e=>e.id===x?.defaultId);if(e&&xe(e,{topic:o,dirKey:m?``:o,groupId:m?h:``,board:d?.board?.id||``,project:f.project||``},_))return;let t=ne(),n=F(I(m?h:o),t),r={};d&&d.board&&d.board.id&&(r.board=d.board.id),f.project&&(r.project=f.project),P(n,{title:``,body:x?be(x.defaultPick(),r):w(``,r)}),_.openPage&&_.openPage(m?{groupId:h,task:t,name:`新任务`}:{dirKey:o,task:t,name:`新任务`})},[d,f.project,m,h,o,_,x]),cloneCur:(0,J.useCallback)(()=>{if(r||i==null||/^draft/i.test(String(i))){W(`草稿没有可克隆的队列任务`);return}H(async()=>{let t=await ce(u?{id:Number(i)}:{id:Number(i),cwd:c?.cwd});W(`已克隆为新任务 #${t.task?.id??t.id}`),E?.();let n=t?.task?.id??t?.id;n!=null&&_.openPage&&(m?_.openPage({groupId:h,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}):_.openPage({dirKey:o,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(克隆)`}))})},[r,i,u,c,m,h,o,_,e,E,H,W]),forkCur:(0,J.useCallback)(()=>{if(r||i==null||/^draft/i.test(String(i))){W(`草稿没有可 Fork 的队列任务`);return}H(async()=>{let t=await de(u?{id:Number(i)}:{id:Number(i),cwd:c?.cwd});W(`已 Fork 为新任务 #${t.task?.id??t.id}(保留任务链)`),E?.();let n=t?.task?.id??t?.id;n!=null&&_.openPage&&(m?_.openPage({groupId:h,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}):_.openPage({dirKey:o,task:String(n),name:`${(e?.title||`任务`).slice(0,30)}(Fork)`}))})},[r,i,u,c,m,h,o,_,e,E,H,W]),openProgress:(0,J.useCallback)(()=>{let e=v||_.model;if(!e)return;let t=f&&f.board?String(f.board):``;s(e,{component:`progress`,name:`进程`,config:t?{groupKey:t,task:i==null?void 0:String(i)}:{dirKey:o||`__GLOBAL__`,task:i==null?void 0:String(i)},location:`right`})},[v,_.model,f,i,o]),openAttachPanel:(0,J.useCallback)(()=>{se(`attach`),setTimeout(()=>j.current?.open(),0)},[se,j])}}function Ue({doc:e,isDraft:n,task:r,taskRow:i,topicKey:a,topic:o,isGlobal:s,dirKey:c,groupAnchored:u,groupId:d,app:f,model:p,tabId:m,refreshLocal:h,closeSelMenu:g,lastSel:_,selMenu:v,dirty:y,setDirty:b,guard:x}){let S=t(),C=(0,J.useCallback)(async()=>{if(n||r==null||/^draft/i.test(String(r)))return null;let e=s?`key=${encodeURIComponent(A)}&id=${Number(r)}`:`cwd=${encodeURIComponent(o?.cwd||``)}&id=${Number(r)}`;return me(e).catch(()=>null)},[n,r,s,o?.cwd]),w=(0,J.useCallback)(()=>{let t=p||f.model;t&&ae(t,{mode:`feedback`,taskLabel:r==null?``:`#`+r,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),prevQuote:String(i?.roundSummary||``).trim()||String(e?.body||``).trim().slice(0,400),src:{dirKey:a||c||`__GLOBAL__`,task:String(r),name:`原文 #${r}`},onSubmit:e=>T(e)})},[p,f.model,r,e,i,a,c]),T=(0,J.useCallback)(({text:t,attachments:c=[],inserts:l=``}={})=>{let p=String(t||``).trim();if(g(),!p&&!(c&&c.length)){S(`写一下反馈`);return}let m=e?.title||`#${r}`;x(async()=>{let t=await C(),g=String(t?.text??``).trim()||String(e?.body??``).trim();if(!g&&!n){S(`拿不到任务当前正文,已取消反馈(防止丢内容)`);return}let _=p||`(见附件)`;l&&(_=`${_}${l}`);let v={base:g,feedback:_,ackSummary:t?.roundSummary||i?.roundSummary||``,feedbackHeading:pe,bold:!0},y=U(v),b=!n&&r!=null&&!/^draft/i.test(String(r))?{forkOf:String(r),forkKind:`reopen`}:{},x=await K(s?{global:!0,text:y,...b}:{cwd:o?.cwd,text:y,...b}),w=String(x?.task?.id??x?.id??``);if(!w){S(`反馈已提交,但未拿到新任务编号`),h?.();return}let T=x?.key||a;P(F(I(T),w),{title:ee(y),body:y}),c?.length&&R(w,c),S(`已反馈「${m}」→ 新任务 #${w}`),h?.(),f.openPage&&(u?f.openPage({groupId:d,task:w,name:`${m.slice(0,24)}(反馈)`}):f.openPage({dirKey:T,task:w,name:`${m.slice(0,24)}(反馈)`}))})},[e,r,i,n,s,o,a,u,d,f,h,g,x,S,C]),E=(0,J.useCallback)(({text:t,attachments:i=[],inserts:c=``,quote:u}={})=>{let d=String(t||``).trim(),f=String(u||_.current||``).trim();if(g(),!d&&!(i&&i.length)){S(`写一下要提的问题`);return}if(!f&&!d){S(`先划选一段再评论`);return}if(n||r==null||/^draft/i.test(String(r))){S(`草稿先提交成任务再评论`);return}let v=e?.title||`#${r}`;x(async()=>{let t=!y&&!c&&!(i&&i.length),n;if(!t){let t=await C(),r=String(t?.text??``).trim()||String(e?.body??``).trim();if(!r){S(`拿不到任务当前正文,已取消评论(防止丢内容)`);return}let i={base:r,feedback:[W(f),d||`(见附件)`,c].filter(Boolean).join(`
8
-
9
- `),ackSummary:``,feedbackHeading:he,bold:!1};n=U(i)}let u=await se({...s?{key:A}:{cwd:o?.cwd},id:Number(r),...n?{text:n}:{},kind:`comment`,quote:f,feedback:d,attachments:(i||[]).map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,url:e.url||``}))}),g=u?.key||a,_=String(u?.task?.id??r),x=String(u?.task?.text??n??``);x&&P(F(I(g),_),{title:ee(x),body:x}),i?.length&&R(_,[...e?.attachments||[],...i]),p&&m&&g!==a&&p.doAction(l.updateNodeAttributes(m,{config:{dirKey:g,task:_}})),b(!1),S(`已回写评论「${v}」#${_}`),h?.()})},[e,r,n,s,o,a,p,m,h,g,_,y,b,x,S,C]);return{fetchServerTask:C,openFeedback:w,spawnFeedbackTask:T,submitCommentInPlace:E,openCommentFromToolbar:(0,J.useCallback)(()=>{let t=String(window.getSelection()||``).trim()||(v?.text?String(v.text):``);if(!t){S(`先划选一段再评论`);return}_.current=t;let n=p||f.model;n&&(ae(n,{mode:`comment`,quote:t,taskLabel:r==null?``:`#`+r,taskTitle:String(e?.title||``).replace(/^#+\s*/,``),src:{dirKey:a||c||`__GLOBAL__`,task:String(r),name:`原文 #${r}`},onSubmit:e=>E({...e,quote:t})}),g())},[e,r,a,c,p,f.model,_,v,E,g,S])}}function We({doc:e,beside:t,topicKey:n,topic:r,task:i,app:a}){let o=(0,J.useMemo)(()=>e?T(e.body):{},[e&&e.body]);return{docFm:o,parentRef:(0,J.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];if(!l)return null;let u=l.trim(),d=(r?.tasks||[]).find(e=>String(e.id)===String(i)?!1:ee(e.text||``)===u||String(e.text||``).includes(`# ${u}`));return d?{dirKey:n,task:String(d.id),name:`#${d.id}`}:null},[t,o.parent,o.parentDir,e?.body,n,r,i]),boardCtx:(0,J.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(e=>!!e).map(e=>({key:e.key,name:e.name}))}},[o.board,a.repoData])}}var Ge=a;function Ke({state:e,onClose:n}){let r=t(),i=e?.data,a=async()=>{try{await navigator.clipboard.writeText(String(i?.rendered||``)),r(`已复制原文`)}catch{r(`复制失败(剪贴板不可用)`)}},o=i?.switches||{},s=i?[`ack ${o.ack?.on?`开(${o.ack.count} 条)`:`关`}`,`模板 全部内置(插件类)`,`持续 get ${i.getLoop?.enabled?`开(${i.getLoop.waitMinutes} 分钟)`:`关`}`].join(` · `):``,c=i?`预览:agent 执行 get 会收到的提示词${i.task?.id?` · #${i.task.id}`:` · 草稿`}`:`预览:agent 执行 get 会收到的提示词`;return(0,Y.jsxs)(Ge,{title:c,size:`wide`,onClose:n,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`mdw-prev-hint`,children:`与 CLI 取任务共用同一份排版;不含「已取得下一条任务…」头部行。`}),(0,Y.jsx)(`span`,{className:`grow`}),(0,Y.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:a,disabled:!i,children:`复制原文`}),(0,Y.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:n,children:`关闭`})]}),children:[e.busy&&(0,Y.jsx)(`div`,{className:`mdw-prev-note`,children:`渲染中…`}),e.error&&(0,Y.jsxs)(`div`,{className:`mdw-prev-note`,children:[`预览失败:`,e.error,/接口不存在/.test(String(e.error))&&(0,Y.jsx)(`div`,{className:`mdw-prev-hint`,children:`本机面板服务较旧:重启面板(结束当前 serve 进程后重新启动)即可生效,刷新页面不够。`})]}),i&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`pre`,{className:`mdw-prev-body`,children:i.rendered||``}),i.segments?.length?(0,Y.jsxs)(`details`,{className:`mdw-prev-seg`,children:[(0,Y.jsxs)(`summary`,{children:[`段落来源(`,i.segments.length,` 段)`]}),(0,Y.jsx)(`ol`,{children:i.segments.map((e,t)=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`span`,{className:`mdw-prev-seg-lab`,children:e.label}),(0,Y.jsxs)(`span`,{className:`mdw-prev-seg-n`,children:[String(e.text||``).length,` 字`]})]},t))}),(0,Y.jsx)(`div`,{className:`mdw-prev-note`,children:`改这些段去「设置 → 提示词 / 模板」;「持续 get」在项目级设置里。`})]}):(0,Y.jsx)(`div`,{className:`mdw-prev-note`,children:`当前没有任何模板段:交付时就只有任务正文。`}),(0,Y.jsx)(`div`,{className:`mdw-prev-switch`,children:s})]})]})}var qe=O;function Je({attachments:e}){let t=e.filter(e=>e.kind===`mdfile`),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)({}),o=async e=>{if(r(e),!i[e]||i[e].error){a(t=>({...t,[e]:{html:``,path:``,stale:!1,missing:!1,loading:!0}}));try{let t=await G(e);a(n=>({...n,[e]:{html:m(String(t.body||``)),path:String(t.absPath||``),stale:!!t.stale,missing:!!t.missing}}))}catch(t){a(n=>({...n,[e]:{html:``,path:``,stale:!1,missing:!1,error:t.message||String(t)}}))}}};if(!t.length)return(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:"没有 md 附件——用 `nx-kv localtask attach --mdfile <本地 md 路径>` 挂一个外部 md 文件。"});let s=n?i[n]:null;return(0,Y.jsxs)(`div`,{className:`mdw-md-tab`,children:[(0,Y.jsx)(`div`,{className:`mdw-md-list`,role:`list`,children:t.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`listitem`,className:`mdw-md-item${n===String(e.id)?` is-on`:``}`,onClick:()=>o(String(e.id)),title:e.absPath||``,children:[(0,Y.jsx)(`span`,{className:`mdw-md-item-name`,children:e.name||`md`}),(0,Y.jsxs)(`span`,{className:`mdw-md-item-path mono`,children:[e.absPath||`(路径为空)`,e.missing?` · 文件已不在`:``]})]},String(e.id)))}),(0,Y.jsxs)(`div`,{className:`mdw-md-view`,children:[n?null:(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`选一条 md 看预览。`}),s?.loading?(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,s?.error?(0,Y.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,s.error]}):null,s&&!s.loading&&!s.error?s.missing?(0,Y.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`源文件已不在:`,s.path||`(路径为空)`]}):(0,Y.jsxs)(`div`,{className:`mdw-md-render`,children:[s.stale?(0,Y.jsx)(`div`,{className:`att-md-warn`,children:`内容已变化(与登记指纹不一致),以下为磁盘当前内容。`}):null,(0,Y.jsx)(`article`,{dangerouslySetInnerHTML:{__html:s.html}})]}):null]})]})}function Ye({dockOpen:t,dockTab:n,dockH:r,dockRef:i,dockMax:a,showDockTab:o,onDockDragStart:c,toggleDockMax:l,setDockOpen:u,canShowGoalLog:f,goalLog:p,openGoalLog:m,isDraft:h,task:g,topic:_,topicKey:v,isGlobal:y,doc:b,id:x,model:S,app:C,refreshLocal:w,markDirty:T,saveDoc:E,persistAtt:ee,attachAreaRef:D,reviewBarRef:O,reviewSumRef:te,taskRow:k,ackOpen:j,setAckOpen:M,ackOverflow:N,ackLong:P,ackHtml:ne,isChainTip:re,latestChild:F,openFeedback:I,openLatestRound:ie,attachments:L}){if(!t)return null;let R=L.filter(e=>e.kind===`mdfile`).length;return(0,Y.jsxs)(`div`,{className:`mdw-dock`,ref:i,style:{height:`${r}px`},children:[(0,Y.jsx)(`div`,{className:`mdw-dock-drag`,role:`separator`,"aria-orientation":`horizontal`,title:`上下拖动调整信息面板高度(双击最大化 / 还原)`,onMouseDown:c,onDoubleClick:l}),(0,Y.jsxs)(`div`,{className:`mdw-dock-head`,children:[(0,Y.jsxs)(`div`,{className:`mdw-dock-tabs`,role:`tablist`,"aria-label":`信息面板`,children:[(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`attach`,className:`mdw-dock-tab${n===`attach`?` is-on`:``}`,onClick:()=>o(`attach`),children:`附件`}),(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`md`,className:`mdw-dock-tab${n===`md`?` is-on`:``}`,onClick:()=>o(`md`),title:`只聚合 kind='mdfile' 的附件(md 预览)`,children:[`md`,R?(0,Y.jsx)(`span`,{className:`mdw-dock-tab-num`,children:R}):null]}),f?(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`check`,className:`mdw-dock-tab${n===`check`?` is-on`:``}`,onClick:m,children:[`check`,(0,Y.jsx)(`span`,{className:`mdw-dock-tab-num`,children:p.data?.count??0})]}):null,(0,Y.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`feedback`,className:`mdw-dock-tab${n===`feedback`?` is-on`:``}`,onClick:()=>o(`feedback`),children:`反馈`})]}),(0,Y.jsxs)(`div`,{className:`mdw-dock-acts`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:l,title:a?`还原面板高度`:`最大化面板高度`,"aria-label":a?`还原面板高度`:`最大化面板高度`,children:(0,Y.jsx)(e,{name:a?`collapse`:`expand`,title:void 0})}),(0,Y.jsx)(`button`,{type:`button`,className:`mdw-dock-act`,onClick:()=>u(!1),title:`关闭面板(底部状态栏仍保留入口)`,"aria-label":`关闭面板`,children:(0,Y.jsx)(e,{name:`x`,title:void 0})})]})]}),(0,Y.jsxs)(`div`,{className:`mdw-dock-body`,children:[n===`attach`?h?(0,Y.jsx)(B,{attachments:b.attachments,onRemove:e=>{let t=(b.attachments||[]).filter(t=>t.id!==e);T(),E(x,{attachments:t}),h||ee(g,t)}}):_?(0,Y.jsx)(qe,{ref:D,host:`task`,hostId:Number(g),hostKey:y?A:void 0,hostCwd:y?void 0:_.cwd,allow:{file:!0,url:!0,folder:!0,task:!0,ref:!0},taskOptions:(_.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status})),onChanged:w,onOpenTask:e=>{C.openPage&&e&&e.seq!=null&&C.openPage({dirKey:e.key||v,task:String(e.seq),name:`#${e.seq}`})},onOpenDoc:e=>{let t=d(e);S&&t&&s(S,{component:`doc`,name:e.split(`/`).pop()||e,config:{docId:t},location:`center`})}}):(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`没有可挂载附件的上下文。`}):null,n===`md`?(0,Y.jsx)(Je,{attachments:L}):null,n===`check`?(0,Y.jsxs)(`div`,{className:`mdw-dock-check`,children:[p.busy&&!p.data?(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`读取中…`}):null,p.error?(0,Y.jsxs)(`div`,{className:`mdw-dock-empty`,children:[`读取失败:`,p.error]}):null,p.data?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mdw-dock-meta mono`,children:[`时间目标 ${p.data.duration||`—`}`,p.data.startedAt?` · 开始 ${p.data.startedAt}`:``,p.data.deadline?` · 截止 ${p.data.deadline}`:` · 尚未开始计时`,p.data.archived?` · 已归档`:``,` · ${p.data.count||0} 轮`]}),(p.data.count||0)>0?(0,Y.jsx)(`div`,{className:`mdw-goal-log`,children:p.data.entries.map((e,t)=>(0,Y.jsxs)(`div`,{className:`mdw-goal-log-row`,children:[(0,Y.jsxs)(`div`,{className:`mdw-goal-log-head mono`,children:[`R`,t+1,` · `,e.checkedAt,` · `,e.reached?`已到点`:`未到点`,` · 已用`,` `,fe(e.elapsedSec),` · 剩余 `,fe(e.remainingSec)]}),e.summary?(0,Y.jsx)(`div`,{className:`mdw-goal-log-body`,children:e.summary}):null,e.progress?(0,Y.jsx)(`div`,{className:`mdw-goal-log-prog`,children:e.progress}):null]},`${e.checkedAt}-${t}`))}):(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`还没有 check 记录——任务领取后每轮 check 会出现在这里。`})]}):null]}):null,n===`feedback`?!h&&k?.completedAt?(0,Y.jsxs)(`div`,{className:`mdw-review`,ref:O,children:[(0,Y.jsxs)(`div`,{className:`mdw-review-main`,children:[(0,Y.jsx)(`span`,{className:`mdw-review-badge`,children:`已完成 · 等待验收`}),(0,Y.jsx)(`span`,{className:`mdw-review-at mono`,children:k.completedAt}),k.roundSummary?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{ref:te,className:`mdw-review-sum${j?` is-open`:``}`,title:j||!(N||P)?`agent 的完成总结(ack)`:`点击下方展开全文`,dangerouslySetInnerHTML:{__html:ne}}),(N||P||j)&&(0,Y.jsx)(`button`,{type:`button`,className:`mdw-review-more`,onClick:()=>M(e=>!e),children:j?`收起`:`展开全文`})]}):null]}),(0,Y.jsx)(`div`,{className:`mdw-review-acts`,children:re?(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:I,title:`新开一条任务携带反馈(原任务不动)`,children:`反馈`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`mdw-review-later`,title:`这条任务已有后续轮次——在旧轮次上反馈会把链分叉,请到最新一轮反馈`,children:`已进入后续轮次`}),F?(0,Y.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:ie,title:`到最新一轮 #${F.id} 反馈`,children:[`去最新一轮 #`,F.id]}):null]})})]}):(0,Y.jsx)(`div`,{className:`mdw-dock-empty`,children:`任务完成后,agent 的完成总结会显示在这里。`}):null]})]})}function Xe({dockOpen:t,dockTab:n,showDockTab:r,setDockOpen:i,canShowGoalLog:a,goalLog:o,openGoalLog:s,isDraft:c,taskRow:l,mdCount:u=0}){return(0,Y.jsxs)(`div`,{className:`mdw-sbar`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`attach`?` is-on`:``}`,onClick:()=>r(`attach`),title:`附件(点击展开信息面板)`,children:[(0,Y.jsx)(e,{name:`list`,title:void 0}),(0,Y.jsx)(`span`,{className:`mdw-sbar-lab`,children:`附件`})]}),(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`md`?` is-on`:``}`,onClick:()=>r(`md`),title:`md 附件预览(点击展开信息面板)`,children:[(0,Y.jsx)(e,{name:`overview`,title:void 0}),(0,Y.jsx)(`span`,{className:`mdw-sbar-lab`,children:`md`}),u>0?(0,Y.jsx)(`span`,{className:`mdw-sbar-num`,children:u}):null]}),a?(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`check`?` is-on`:``}`,onClick:s,title:`时间目标每轮 check(点击展开信息面板)`,children:[(0,Y.jsx)(e,{name:`clock`,title:void 0}),(0,Y.jsx)(`span`,{className:`mdw-sbar-lab`,children:`check`}),(0,Y.jsx)(`span`,{className:`mdw-sbar-num`,children:o.data?.count??0})]}):null,(0,Y.jsxs)(`button`,{type:`button`,className:`mdw-sbar-item${t&&n===`feedback`?` is-on`:``}`,onClick:()=>r(`feedback`),title:`完成总结 / 反馈(点击展开信息面板)`,children:[(0,Y.jsx)(e,{name:`edit`,title:void 0}),(0,Y.jsx)(`span`,{className:`mdw-sbar-lab`,children:`反馈`})]}),(0,Y.jsx)(`span`,{className:`mdw-sbar-grow`}),!c&&l?(0,Y.jsx)(`span`,{className:`mdw-sbar-stat`,title:`任务状态`,children:(0,Y.jsx)(E,{t:l,title:void 0})}):null,(0,Y.jsx)(`button`,{type:`button`,className:`mdw-sbar-chev${t?` is-open`:``}`,onClick:()=>i(e=>!e),title:t?`收起信息面板`:`展开信息面板`,"aria-expanded":t,"aria-label":t?`收起信息面板`:`展开信息面板`,children:(0,Y.jsx)(e,{name:`chevron`,title:void 0})})]})}function Ze({goal:e,setGoalDraft:t,goalEditable:n,goalPromptEditable:r,declaredGoal:i,openGoalLog:a,markDirty:o,task:s}){let c=(e.duration||``).trim(),l=(e.prompt||``).trim(),u=!!r;return{goalBadge:c||l?{label:`⏱ ${c||`目标`}`,title:l||(n?`任务级时间目标(在「更多」里设置;领取即计时)`:`已领取计时,时长不可改(附加要求仍可编辑)`)}:null,goalMenu:n||u||i?(0,Y.jsxs)(`div`,{className:`mdw-goal-menu`,children:[(0,Y.jsx)(`div`,{className:`mdw-goal-menu-lab`,children:`时间目标`}),n?(0,Y.jsx)(`input`,{className:`mdw-goal-dur mono`,value:e.duration,placeholder:`2h / 90m / 30分钟,留空不带`,onChange:n=>{t({...e,duration:n.target.value}),o()}}):(0,Y.jsxs)(`span`,{className:`mdw-goal-ro mono`,title:`已领取计时,时长不可改`,children:[i?.duration||`—`,` · 已领取计时`]}),u?(0,Y.jsx)(`input`,{className:`mdw-goal-prompt`,value:e.prompt,placeholder:`附加要求(可选;领取后仍可改,下一轮 check 即生效)`,onChange:n=>{t({...e,prompt:n.target.value}),o()}}):i?.prompt?(0,Y.jsx)(`span`,{className:`mdw-goal-ro`,title:`任务已到终态,附加要求不可改`,children:i.prompt}):null,i&&s!=null?(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:a,title:`查看时间目标的每轮 check 记录`,children:`查看每轮 check 日志`}):null]}):null}}var Qe={origin:`起点`,reopen:`反馈`,comment:`评论`};function $e({historyId:e,historyNode:t,closeBesideSelf:n}){let r=Qe[String(t?.kind??``)]||`节点`,i=t?q(t.text||``,t.attachments||[]):``;return(0,Y.jsxs)(`div`,{className:`mdw is-beside`,children:[(0,Y.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,Y.jsxs)(`span`,{className:`mdw-beside-lab`,children:[`链节点 · `,r,` #`,e]}),(0,Y.jsx)(`span`,{className:`grow`}),(0,Y.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭`,"aria-label":`关闭`,onClick:n,children:`×`})]}),(0,Y.jsx)(`div`,{className:`mdw-hist-ro`,children:t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mdw-hist-meta`,children:[(0,Y.jsx)(`span`,{children:t.at||`—`}),t.quote?(0,Y.jsxs)(`span`,{children:[`锚定:`,t.quote.slice(0,80)]}):null,t.feedback?(0,Y.jsxs)(`span`,{children:[`反馈:`,t.feedback.slice(0,80)]}):null,t.summary?(0,Y.jsxs)(`span`,{children:[`上轮总结:`,t.summary.slice(0,80)]}):null]}),(0,Y.jsx)(`article`,{className:`md-body`,dangerouslySetInnerHTML:{__html:i||`<p class="muted">(空)</p>`}})]}):(0,Y.jsxs)(`div`,{className:`muted`,children:[`找不到链节点 #`,e]})})]})}function et({boardCtx:e,docFm:t,goalEditable:n,doc:r,id:i,markDirty:a}){if(!e)return null;let o=e.members.find(e=>e.key===t.project);return(0,Y.jsxs)(`div`,{className:`mdw-goal`,children:[(0,Y.jsx)(`span`,{className:`mdw-goal-lab`,title:`归属项目(限本组成员):决定提交进哪个项目的队列;由组面板「新增任务」创建时自动携带本组语义`,children:`归属项目`}),n?(0,Y.jsx)(`select`,{className:`mdw-proj-pick`,value:t.project||``,onChange:n=>{P(i,{body:w(r.body,{...t,board:e.board.id,project:n.target.value})}),a()},children:e.members.map(e=>(0,Y.jsx)(`option`,{value:e.key,children:e.name},e.key))}):(0,Y.jsx)(`span`,{className:`mdw-proj-ro`,title:`归属项目(在本组创建时写入,随任务走)`,children:o?.name||t.project||`—`})]})}function tt({task:e,app:t,groupAnchored:n,groupId:r,isGlobal:i,dirKey:a}){return(0,Y.jsx)(`div`,{className:`mdw`,children:(0,Y.jsxs)(`div`,{className:`pad stack`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(`strong`,{children:[`找不到任务 #`,e]})}),(0,Y.jsx)(`div`,{className:`hint`,children:`它可能已被删除(软删除可用 nx-kv localtask task restore 恢复),或这个深链写错了。`}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>t.onNavigate&&t.onNavigate(n?`#/group/`+encodeURIComponent(r||``):i?`#/global`:`#/dir/`+encodeURIComponent(a||``)),children:`回到目录`})})]})})}function nt({onClose:e}){return(0,Y.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,Y.jsx)(`span`,{className:`mdw-beside-lab`,children:`原文(旁路)`}),(0,Y.jsx)(`span`,{className:`grow`}),(0,Y.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭原文面板`,"aria-label":`关闭原文面板`,onClick:e,children:`×`})]})}var rt=Le;function it({dirKey:e,groupId:n,task:i,beside:a=!1,tabId:o,model:s,historyId:d=null}){let p=u(),m=t(),{dialog:y,node:S}=r(),C=p.rows||[],w=p.refreshLocal,T=p.tpl,E=!(!n||e),D=(0,J.useMemo)(()=>E?ge(C,p.repoData&&p.repoData.boards||[],n,i):null,[E,C,p.repoData,n,i]),O=D&&D.topic&&D.topic.key||e||``,k=!E&&(!O||O===`__GLOBAL__`),N=M(i),ne=I(E&&N?n:O),L=F(ne,i),z=(0,J.useMemo)(()=>E?D&&D.topic||null:k?C.find(e=>e.isGlobal)||null:C.find(e=>e.key===O)||null,[C,O,k,E,D]),B=(0,J.useMemo)(()=>(z?.tasks||[]).find(e=>String(e.id)===String(i))||null,[z,i]),oe=re(),V=oe[L]||null,U=V&&V.mode===`edit`?`edit`:`split`,{dockOpen:se,setDockOpen:W,dockTab:ce,dockH:le,dockRef:G,dockMax:ue,showDockTab:K,onDockDragStart:de,toggleDockMax:fe}=te(),{goalDraft:pe,setGoalDraft:me,goal:he,goalEditable:_e,goalPromptEditable:ye,declaredGoal:xe,goalLog:Ce,loadGoalLog:we,canShowGoalLog:Te}=Re({id:L,isDraft:N,topicKey:O,task:i,taskRow:B}),{chainNodes:Ee,historyNode:De,isChainTip:ke,latestChild:Ae,openLatestRound:Me,openHistoryBeside:Pe}=ze({isDraft:N,task:i,taskRow:B,topicKey:O,topic:z,isGlobal:k,groupAnchored:E,groupId:n,app:p,model:s||null,historyId:d,toast:m}),{selMenu:X,setSelMenu:Ie,lastSel:Le,placeSelMenu:Ge,onEditorTextSel:qe,closeSelMenu:Je}=Be({id:L}),{ackOpen:Qe,setAckOpen:it,ackOverflow:at,reviewSumRef:ot,ackLong:st}=Ve({id:L,taskRow:B,dockTab:ce,dockOpen:se}),[ct,lt]=(0,J.useState)(null),[ut,dt]=(0,J.useState)(!1),[ft,pt]=(0,J.useState)(!1),[mt,ht]=(0,J.useState)(!1),gt=(0,J.useRef)(null),_t=(0,J.useRef)(null),vt=(0,J.useRef)(null),yt=(0,J.useRef)(null),bt=(0,J.useRef)(null),xt=(0,J.useRef)(null),St=(0,J.useRef)(new Map),[Z,Ct]=(0,J.useState)([]);(0,J.useEffect)(()=>{let e=!0,t=B;if(!t||!t.id)return;let n=new URLSearchParams({id:String(t.id)});return O?n.set(`key`,O):t.cwd&&n.set(`cwd`,t.cwd),H(n.toString()).then(t=>{e&&Ct(t&&(t.attachments||t.data?.attachments)||[])}).catch(()=>{e&&Ct([])}),()=>{e=!1}},[B,O]);let wt=(0,J.useMemo)(()=>V?q(g(V.body),Z.length?Z:V.attachments):``,[V,Z]),Tt=(0,J.useMemo)(()=>B?.roundSummary?q(B.roundSummary):``,[B?.roundSummary]),Et=(0,J.useMemo)(()=>V?Oe(V.body):[],[V&&V.body]),[Dt,Ot]=(0,J.useState)(null);(0,J.useEffect)(()=>{let e=yt.current;if(!e)return;let t=()=>e.closest(`.mdw-lp`)||e.closest(`.mdw-preview`)||null;Ot(t());let n=typeof MutationObserver<`u`?new MutationObserver(()=>Ot(t())):null;return n?.observe(e,{childList:!0,subtree:!0}),()=>n?.disconnect()},[V&&V.mode]);let kt=(0,J.useCallback)(e=>e().catch(e=>m(String(e.message||e))),[m]),Q=(0,J.useCallback)(()=>ht(!0),[]),{docFm:At,parentRef:$,boardCtx:jt}=We({doc:V,beside:a,topicKey:O,topic:z,task:i,app:p});(0,J.useEffect)(()=>{oe[L]||(N?ie(L,{title:``,body:T?be(T.defaultPick(),E?{board:n}:{}):``}):B&&ie(L,{title:ee(B.text),body:B.text}))},[L,N,B,E,n]);let{composeText:Mt,submit:Nt,importMd:Pt,delTask:Ft,canComplete:It,canCancel:Lt,closeTask:Rt,canPlan:zt,togglePlan:Bt,addFiles:Vt,newTask:Ht,cloneCur:Ut,forkCur:Wt,openProgress:Gt,openAttachPanel:Kt}=He({doc:V,id:L,isDraft:N,task:i,taskRow:B,topicKey:O,topic:z,isGlobal:k,boardCtx:jt,docFm:At,groupAnchored:E,groupId:n,rows:C,app:p,model:s||null,tabId:o,tpl:T,refreshLocal:w,markDirty:Q,histRef:St,editorApiRef:xt,attachAreaRef:vt,setDirty:ht,goal:he,goalEditable:_e,goalPromptEditable:ye,declaredGoal:xe,guard:kt,dialog:y,showDockTab:K}),qt=(0,J.useRef)(!1);(0,J.useEffect)(()=>{Se(L)?.submit&&(qt.current=!0)},[L]),(0,J.useEffect)(()=>{qt.current&&V&&N&&(qt.current=!1,Nt())},[V,N,Nt]);let{openFeedback:Jt,submitCommentInPlace:Yt,openCommentFromToolbar:Xt}=Ue({doc:V,isDraft:N,task:i,taskRow:B,topicKey:O,topic:z,isGlobal:k,dirKey:e,groupAnchored:E,groupId:n,app:p,model:s||null,tabId:o,refreshLocal:w,closeSelMenu:Je,lastSel:Le,selMenu:X,dirty:mt,setDirty:ht,guard:kt}),Zt=(0,J.useCallback)(()=>{K(`check`),we()},[K,we]),{goalBadge:Qt,goalMenu:$t}=Ze({goal:he,goalDraft:pe,setGoalDraft:me,goalEditable:_e,goalPromptEditable:ye,declaredGoal:xe,openGoalLog:Zt,markDirty:Q,task:i}),en=(0,J.useCallback)(()=>{lt({busy:!0});let e={cwd:k?z?.cwd||void 0:z?.cwd,key:k?A:O,...N?{text:Mt((V?.title||``).trim()||`未命名任务`,V?.body||``)}:{id:Number(i)}};ve(e).then(e=>lt({data:e})).catch(e=>lt({error:String(e.message||e)}))},[k,z?.cwd,O,N,V?.title,V?.body,i,Mt]),tn=(e,t=`typing`)=>{if(!V)return;v(St.current,L,{title:V.title,body:V.body},t),Q();let n={title:e};U!==`split`&&/^# (?!#)/m.test(V.body)&&(n.body=V.body.replace(/^# (?!#).+$/m,`# ${e||`未命名任务`}`)),P(L,n)},nn=(e,t=`op`)=>{if(!V)return;v(St.current,L,{title:V.title,body:V.body},t),Q();let n={body:e};U!==`split`&&(n.title=ee(e)),P(L,n)},rn=()=>{if(!V)return;let e=h(St.current,L,{title:V.title,body:V.body});e&&(P(L,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>xt.current?.caretFromDiff?.(V.body,e.body)))},an=()=>{if(!V)return;let e=b(St.current,L,{title:V.title,body:V.body});e&&(P(L,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>xt.current?.caretFromDiff?.(V.body,e.body)))},on=e=>{if(!V||U===`edit`)return;let t=e.target instanceof Element?e.target:null;if(t?.closest(`#mdw-sel-menu`)||t?.closest(`textarea`))return;let n=window.getSelection(),r=String(n||``).trim();if(!r||r.length<1){Ie(null);return}if(!n)return;if(!yt.current?.contains(n.anchorNode)){Ie(null);return}let i=e=>e?.nodeType===3?e.parentElement:e,a=i(n.anchorNode)?.closest?.(`.mdw-lp-block`),o=i(n.focusNode)?.closest?.(`.mdw-lp-block`),s=null;if(a&&o&&a!==o&&yt.current?.contains(o)){let e=Number(a.getAttribute(`data-i`)),t=Number(o.getAttribute(`data-i`));Number.isInteger(e)&&Number.isInteger(t)&&e!==t&&(s=[Math.min(e,t),Math.max(e,t)])}let c=n.getRangeAt(0),l=c.getClientRects(),u=l[l.length-1]??c.getBoundingClientRect();Ge(`task`,r,u.right-60,u.bottom+8,s?{blockRange:s}:{})},sn=(0,J.useCallback)(()=>{if(!$){m(`这条任务没有可定位的原文`);return}let e=s||p.model;e&&c(e,{component:`page`,name:$.name||`原文 ${$.task}`,config:{dirKey:$.dirKey,task:String($.task)}})},[$,s,p.model,m]),cn=(0,J.useCallback)(()=>{let e=s||p.model;e&&o&&e.doAction(l.deleteTab(o))},[s,p.model,o]),ln=e=>{_t.current&&(_t.current.accept=e),_t.current?.click()};return(0,J.useEffect)(()=>{if(!$||a)return;let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&String(e.key||``).toLowerCase()===`o`&&(e.preventDefault(),sn())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[$,a,sn]),d==null?V?(0,Y.jsxs)(`div`,{className:`mdw${a?` is-beside`:``}`,"data-mode":U,onMouseUp:on,children:[S,ct&&(0,Y.jsx)(Ke,{state:ct,onClose:()=>lt(null)}),(0,Y.jsx)(rt,{open:ft,nodes:Ee,onOpenNode:Pe,onClose:()=>pt(!1)}),a&&(0,Y.jsx)(nt,{onClose:cn}),(0,Y.jsxs)(`div`,{className:`mdw-main`,children:[(0,Y.jsxs)(`div`,{className:`mdw-top`,children:[(0,Y.jsx)(j,{}),(0,Y.jsxs)(`div`,{className:`mdw-head`,children:[(0,Y.jsx)(`div`,{className:`mdw-title`,children:N?V.title||`新 MD 任务`:V.title||`任务`}),(0,Y.jsxs)(`div`,{className:`mdw-path`,children:[k?`全局任务池`:z?.cwd||z?.name||`—`,!k&&z?.cwdExists===!1&&(0,Y.jsxs)(`span`,{className:`mdw-path-warn`,title:`工作目录已不存在:目录被删除或磁盘未挂载。任务本身还在,只是不再有对应目录。`,children:[` `,`· 目录已不存在`]}),N?` / (${i})`:` / #${i}`,mt?` · 未保存`:``]})]})]}),(0,Y.jsx)(et,{boardCtx:jt,docFm:At,goalEditable:_e,doc:V,id:L,markDirty:Q}),(0,Y.jsx)(_,{mode:U,onMode:e=>P(L,{mode:e}),showMark:U!==`edit`,submitLabel:N?`提交为任务`:`保存并同步`,onNew:Ht,onSubmit:Nt,onChain:N?null:()=>pt(!0),onPreview:en,onImg:()=>ln(`image/*`),onAtt:()=>N?ln(`image/*,.pdf,.zip,.txt,.json,.csv`):Kt(),onImport:()=>gt.current?.click(),onClone:N?null:Ut,onFork:N?null:Wt,onComplete:It?()=>Rt(`done`):null,onPlan:zt?Bt:null,planLabel:String(B?.status||``)===`plan`?`转回待领取`:`转为草稿(plan)`,onCancelTask:Lt?()=>Rt(`cancel`):null,onMark:Xt,onDraft:()=>m(`草稿随页签保留(刷新后需从侧栏或页签重新打开)`),onDelete:N?null:Ft,onOverview:()=>p.onNavigate&&p.onNavigate(`#/overview`),onProg:Gt,onSource:$?sn:null,onShortcuts:()=>dt(!0),goalBadge:Qt,goalMenu:$t}),(0,Y.jsx)(f,{ref:yt,mode:U,title:V.title,body:V.body,previewHtml:wt,onTitle:tn,onBody:nn,attachments:Z.length?[...V.attachments,...Z]:V.attachments,docKey:L,editorApiRef:xt,onFiles:Vt,onTextSel:qe,onSave:Nt,onUndo:rn,onRedo:an,onCloseSelMenu:Je,attachHost:N?null:{host:`task`,hostId:Number(i),hostKey:k?A:void 0,hostCwd:k?void 0:z?.cwd,allow:{file:!0,url:!0,folder:!0,task:!0,ref:!0},taskOptions:(z?.tasks||[]).map(e=>({id:e.id,text:e.text,status:e.status}))}}),(0,Y.jsx)(Ye,{dockOpen:se,dockTab:ce,dockH:le,dockRef:G,dockMax:ue,showDockTab:K,onDockDragStart:de,toggleDockMax:fe,setDockOpen:W,canShowGoalLog:Te,goalLog:Ce,openGoalLog:Zt,isDraft:N,task:i,topic:z,topicKey:O,isGlobal:k,doc:V,id:L,model:s||null,app:p,refreshLocal:w,markDirty:Q,saveDoc:P,persistAtt:R,attachAreaRef:vt,reviewBarRef:bt,reviewSumRef:ot,taskRow:B,ackOpen:Qe,setAckOpen:it,ackOverflow:at,ackLong:st,ackHtml:Tt,isChainTip:ke,latestChild:Ae,openFeedback:Jt,openLatestRound:Me,attachments:Z.length?Z:V.attachments}),(0,Y.jsx)(Xe,{dockOpen:se,dockTab:ce,showDockTab:K,setDockOpen:W,canShowGoalLog:Te,goalLog:Ce,openGoalLog:Zt,isDraft:N,taskRow:B,mdCount:(Z.length?Z:V.attachments).filter(e=>e.kind===`mdfile`).length})]}),(0,Y.jsx)(je,{nodes:Et,scrollRoot:Dt}),(0,Y.jsx)(Ne,{at:X,onFormat:e=>{xt.current?.format?.(e),Je()},onCompose:()=>{let t=s||p.model;if(!t)return;let n=String(X?.text||Le.current||``);ae(t,{mode:`comment`,quote:n,taskLabel:i==null?``:`#`+i,taskTitle:String(V?.title||``).replace(/^#+\s*/,``),src:{dirKey:O||e||`__GLOBAL__`,task:String(i),name:`原文 #${i}`},onSubmit:e=>Yt({...e,quote:n})}),Je()},onCopy:()=>{let e=X?.blockRange,t=``;if(e&&V){let n=x(V.body);e[1]<n.length&&(t=n.slice(e[0],e[1]+1).filter(e=>String(e??``).trim()).join(`
10
-
11
- `))}navigator.clipboard?.writeText(t||Le.current||X?.text||``),m(`已复制`),Je()},onDelete:X?.blockRange?()=>{let e=X.blockRange;e&&(xt.current?.deleteBlockRange?.(e[0],e[1])?m(`已删除 ${e[1]-e[0]+1} 个块(Ctrl+Z 可撤销)`):m(`选区已失效`),Je())}:void 0}),(0,Y.jsx)(`input`,{ref:_t,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=Array.from(e.target.files||[]);e.target.value=``,t.length&&Vt(t)}}),(0,Y.jsx)(`input`,{ref:gt,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&Pt(t)}}),ut&&(0,Y.jsx)(Fe,{onClose:()=>dt(!1)})]}):p.localReady===!1||N?(0,Y.jsx)(`div`,{className:`mdw`,children:(0,Y.jsx)(`div`,{className:`pad muted`,children:`载入中…`})}):(0,Y.jsx)(tt,{task:i,app:p,groupAnchored:E,groupId:n,isGlobal:k,dirKey:e}):(0,Y.jsx)($e,{historyId:d,historyNode:De,closeBesideSelf:cn})}export{it as default};
@@ -1 +0,0 @@
1
- var e=new Map,t=e=>String(e||``);function n(n,r){let i=t(n);i&&e.set(i,{...r})}function r(n){let r=t(n);if(!r)return;let i=e.get(r);return i&&e.delete(r),i}export{r as n,n as t};
@@ -1,11 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CMjG5NVU.js","assets/popup-D8KWI6-Q.js","assets/popup-BAvk7J7u.css","assets/workspace-D3jbcTwf.js","assets/repo-form-modal-BD4N37MI.js","assets/button-BEWXOABr.js","assets/button-DA4lNJeC.css","assets/doc-D4po3sDc.js","assets/app-context-DDQnrPSP.js","assets/md-history-CZUF_FhN.js","assets/frontmatter-CN6IlxWU.js","assets/status-tag-BD_0iWMB.js","assets/md-history-1h2zairf.css","assets/use-rail-drag-ufwy2XZB.js","assets/list-filter-D-x94TvA.js","assets/route-crumb-BcDPd7Ht.js","assets/board-view-BVennxTs.js","assets/doc-Iuxssa-b.css","assets/model-Cc2EoUQp.js","assets/render-template-body-bXdedFig.js","assets/index-uMjSWNVr.css"])))=>i.map(i=>d[i]);
2
- import{a as e,c as t,d as n,i as r,m as i,u as a}from"./popup-D8KWI6-Q.js";import{v as o}from"./workspace-D3jbcTwf.js";import{n as s}from"./app-context-DDQnrPSP.js";import{t as c}from"./button-BEWXOABr.js";import{a as l,d as u,i as d,n as f,r as p,s as m,t as h}from"./md-history-CZUF_FhN.js";import{n as g,t as _}from"./list-filter-D-x94TvA.js";import{n as v,t as y}from"./route-crumb-BcDPd7Ht.js";import{a as b,f as x,l as S,n as C,o as w,p as T}from"./index-CMjG5NVU.js";import{a as E,i as D,n as O,o as k,t as A}from"./fill-session-fHxQHFaD.js";import{t as j}from"./manage-session-CS8UvmUd.js";import{t as M}from"./task-intent-CX5DZccN.js";var N=i(n(),1),P=a(),F={topic:`目录`,repo:`项目`,group:`组`};function I(){let e=s(),t=e.rows||[],n=e.repoData?.repos||[],r=e.repoData?.boards||[];return(0,N.useMemo)(()=>{let e=new Map;for(let n of t)n&&n.key&&e.set(String(n.key),n.name||n.key);let i=new Map;for(let e of n)e&&e.key&&(e.type||`repo`)!==`group`&&i.set(String(e.key),e.name||e.key);let a=new Map;for(let e of n)e&&(e.type||``)===`group`&&e.key&&a.set(String(e.key),e.name||e.key);for(let e of r){let t=String(e&&(e.key||e.id)||``);t&&a.set(t,e&&e.name||t)}return{topicByKey:e,repoByKey:i,groupByKey:a,topics:t,repos:n,boards:r}},[t,n,r])}function L(e,t){if(e===`*`)return`全局`;let n=String(e).indexOf(`:`);if(n<0)return String(e);let r=String(e).slice(0,n),i=String(e).slice(n+1),a=F[r]||r,o=``;return r===`topic`?o=t.topicByKey.get(i)||``:r===`repo`?o=t.repoByKey.get(i)||``:r===`group`&&(o=t.groupByKey.get(i)||``),o?`${a} · ${o}`:`${a} ${/^[0-9a-f]{16}$/.test(i)?`${i.slice(0,6)}…`:i}`}function R({scope:e,onChange:n,originTopic:r=``,catalog:i,classPrefix:a=`setp`}){let o=t(),s=I(),c=i||s,[l,u]=(0,N.useState)(null),d=Array.isArray(e)?e:[],f=d.includes(`*`),p=d.filter(e=>e!==`*`),m=a,h=r?c.topicByKey.get(r)||(/^[0-9a-f]{16}$/.test(r)?`${r.slice(0,6)}…`:r):``,g=async e=>{try{await n(e)}catch(e){o(String(e.message||e))}},_=async e=>{if(d.includes(e)){o(`已经在可见范围里了`),u(null);return}await g([...d,e]),u(null)},v=(0,N.useMemo)(()=>{if(l===`topic`)return(c.topics||[]).filter(e=>e&&e.key).map(e=>({entry:`topic:${e.key}`,label:e.name||e.key,sub:e.cwd||``}));if(l===`repo`)return(c.repos||[]).filter(e=>e&&e.key&&(e.type||`repo`)!==`group`&&e.key!==`__unbound__`).map(e=>({entry:`repo:${e.key}`,label:e.name||e.key,sub:e.key}));if(l===`group`){let e=new Set,t=[];for(let n of c.repos||[])n&&(n.type||``)===`group`&&n.key&&!e.has(n.key)&&(e.add(n.key),t.push({entry:`group:${n.key}`,label:n.name||n.key,sub:n.key}));for(let n of c.boards||[]){let r=n&&(n.key||n.id);r&&!e.has(r)&&(e.add(r),t.push({entry:`group:${r}`,label:n&&n.name||r,sub:String(r)}))}return t}return[]},[l,c]);return(0,P.jsxs)(`div`,{className:`${m}-scope-block`,children:[(0,P.jsx)(`div`,{className:`${m}-scope`,children:d.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:`${m}-scope-chip on`,title:`${e} —— 点击移除`,onClick:()=>g(d.filter(t=>t!==e)),children:[L(e,c),` ×`]},e))}),(0,P.jsxs)(`div`,{className:`${m}-scope-add`,children:[(0,P.jsx)(`span`,{className:`${m}-scope-add-label`,children:`添加`}),(0,P.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`,disabled:f,title:f?`已绑定全局`:`加上「全局」绑定(与目录/项目/组平级)`,onClick:()=>!f&&g([`*`,...p]),children:`全局`}),[`topic`,`repo`,`group`].map(e=>(0,P.jsx)(`button`,{type:`button`,className:`${m}-scope-add-btn`+(l===e?` on`:``),onClick:()=>u(l===e?null:e),children:F[e]},e)),h?(0,P.jsxs)(`span`,{className:`${m}-scope-origin`,title:`创建于主题 ${r}`,children:[`创建于 `,h]}):null]}),l&&(0,P.jsx)(`div`,{className:`${m}-scope-pick`,role:`listbox`,"aria-label":`选择可见对象`,children:v.length?v.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:`${m}-scope-pick-it`,disabled:d.includes(e.entry),title:e.sub||e.entry,onClick:()=>_(e.entry),children:[(0,P.jsx)(`span`,{className:`${m}-scope-pick-name`,children:e.label}),d.includes(e.entry)?(0,P.jsx)(`span`,{className:`${m}-scope-pick-done`,children:`已加`}):null]},e.entry)):(0,P.jsx)(`div`,{className:`${m}-scope-pick-empty`,children:`暂无可选项`})})]})}function z(e){return String(e||``).split(`
3
- `).map(e=>e.trim().replace(/^#{1,6}\s+/,``).replace(/^[-*+]\s+\[[ x]\]\s*/i,``).replace(/^[-*+]\s+/,``).replace(/^>\s?/,``).replace(/\{\{\s*([^}{\s][^{}]*?)\s*\}\}/g,`〔$1〕`)).filter(Boolean).slice(0,2).join(` · `)}function B(){let n=s(),i=n.tpl,a=t(),{dialog:o,node:l}=r(),[d,f]=(0,N.useState)(null),[p,m]=(0,N.useState)(null),[h,v]=(0,N.useState)(!1),[y,b]=(0,N.useState)(``),x=e=>n.onNavigate?.(e);if(!i)return(0,P.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,P.jsx)(`div`,{className:`muted`,style:{padding:20},children:`模板服务未就绪…`})});if(i.unsupported)return(0,P.jsx)(`div`,{className:`rp-page tpl-page`,children:(0,P.jsx)(`div`,{className:`muted`,style:{padding:20},children:`当前服务比面板旧——重启面板后才有模板功能。`})});let S=i.templates||[],C=_(S,y,e=>[e.name,z(e.body),(e.scope||[]).join(` `)]),w=async(e,t)=>{if(!h){v(!0);try{await e(),t&&a(t)}catch(e){a(String(e.message||e))}finally{v(!1)}}},T=async e=>{await o({title:`删除模板「${e.name}」`,danger:!0,okText:`删除`})&&await w(()=>i.remove(e.id),`已删除「${e.name}」`)};return(0,P.jsxs)(`div`,{className:`rp-page tpl-page`,children:[l,(0,P.jsxs)(`div`,{className:`page-head`,children:[(0,P.jsxs)(`div`,{className:`title-block`,children:[(0,P.jsxs)(`h2`,{children:[(0,P.jsx)(e,{name:`list`,size:16}),` 任务模板`]}),(0,P.jsxs)(`p`,{className:`muted tpl-head-note`,children:[`新建任务时的正文骨架;带 `,(0,P.jsx)(`code`,{children:`{{content}}`}),` 的段落可在填写页填值。`]})]}),(0,P.jsx)(`div`,{className:`acts`,children:(0,P.jsxs)(c,{variant:`primary`,small:!0,disabled:h,onClick:()=>x(`#/templates/new`),children:[(0,P.jsx)(e,{name:`plus`,size:13}),` 新建`]})})]}),!S.length&&(0,P.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`还没有模板(内置默认模板加载中…)。`}),S.length>1?(0,P.jsx)(`div`,{className:`tpl-search`,children:(0,P.jsx)(g,{value:y,onChange:b,placeholder:`搜索名称 / 正文 / 可见范围…`,title:`过滤任务模板`,count:C.length,className:`wide`})}):null,(0,P.jsxs)(`div`,{className:`tpl-list`,children:[C.map(t=>{let n=t.id===i.defaultId,r=d===t.id,a=p===t.id,o=k(t.body);return(0,P.jsxs)(`div`,{className:`tpl-card`+(n?` is-default`:``),children:[(0,P.jsxs)(`div`,{className:`tpl-card-head`,children:[(0,P.jsx)(`span`,{className:`tpl-card-name`,children:t.name}),n&&(0,P.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,P.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`}),o.length>0&&(0,P.jsxs)(`span`,{className:`tpl-badge slot`,title:o.join(`、`),children:[(0,P.jsx)(e,{name:`list`,size:11}),` `,o.length]}),(0,P.jsx)(`span`,{className:`grow tpl-card-grow`}),(0,P.jsxs)(`div`,{className:`tpl-card-acts`,children:[(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:a?`收起预览`:`预览`,onClick:()=>m(a?null:t.id),children:(0,P.jsx)(e,{name:`monitor`,size:14})}),(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`+(r?` is-on`:``),title:`可见范围`,disabled:h,onClick:()=>f(r?null:t.id),children:(0,P.jsx)(e,{name:`globe`,size:14})}),(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,disabled:h,onClick:()=>x(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,P.jsx)(e,{name:`edit`,size:14})}),!n&&(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:h,onClick:()=>w(()=>i.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,P.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:h,onClick:()=>T(t),children:(0,P.jsx)(e,{name:`trash`,size:14})})]})]}),(0,P.jsx)(`div`,{className:`tpl-card-sum`,children:z(t.body)||`(空模板)`}),r&&(0,P.jsx)(`div`,{className:`tpl-card-scope`,children:(0,P.jsx)(R,{scope:t.scope,originTopic:t.originTopic,onChange:e=>i.update(t.id,{scope:e})})}),a&&(0,P.jsx)(`div`,{className:`tpl-preview`,children:(0,P.jsx)(`div`,{className:`tpl-preview-body mdw-lp-view`,dangerouslySetInnerHTML:{__html:u(D(t.body,t.values))}})})]},t.id)}),S.length&&!C.length?(0,P.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`(没有匹配的模板)`}):null]})]})}function V({config:n}){let r=s(),i=t(),a=(0,N.useMemo)(()=>O(n?.id),[n?.id]),o=(0,N.useMemo)(()=>(r.tpl?.templates||[]).find(e=>e.id===(a||{})?.templateId)||null,[r.tpl?.templates,a]),l=(0,N.useMemo)(()=>o?k(o.body):[],[o]),[u,d]=(0,N.useState)(()=>{let e={};for(let t of l)e[t]=String((o?.values||{})[t]??``);return e});if(!a||!o)return(0,P.jsxs)(`div`,{className:`rp-page tpl-fill-page`,children:[(0,P.jsx)(y,{}),(0,P.jsx)(`div`,{className:`pad muted`,children:`参数会话已失效——请从「新建任务」下拉重新选择模板。`})]});let f=(e,t)=>d(n=>({...n,[e]:t})),p=e=>{let t={};a.board&&(t.board=a.board),a.project&&(t.project=a.project);let s=E({id:o.id,body:o.body,values:o.values},t,u),c=S(),l=a.groupId||a.dirKey||``,d=w(T(l),c);x(d,{title:``,body:s}),e&&M(c,{submit:!0}),A(n?.id);let f=a.groupId?{groupId:a.groupId,task:c,name:`新任务`}:{dirKey:a.dirKey,task:c,name:`新任务`};r.openPage?.(f),i(e?`正在提交任务…`:`已进入草稿编辑`)};return(0,P.jsxs)(`div`,{className:`rp-page tpl-fill-page`,children:[(0,P.jsx)(y,{}),(0,P.jsxs)(`div`,{className:`page-head`,children:[(0,P.jsxs)(`div`,{className:`title-block`,children:[(0,P.jsxs)(`h2`,{children:[(0,P.jsx)(e,{name:`list`,size:16}),` 填写模板参数`]}),(0,P.jsxs)(`p`,{className:`muted tpl-head-note`,children:[`「`,o.name,`」· 全部可选,留空即为空白。生成的是纯文本任务,编辑页不会再出现槽位框。`]})]}),(0,P.jsx)(`div`,{className:`acts`,children:(0,P.jsxs)(c,{variant:`secondary`,small:!0,onClick:()=>r.onNavigate?.(v()||`#/templates`),children:[(0,P.jsx)(e,{name:`back`,size:13}),` 返回`]})})]}),(0,P.jsx)(`div`,{className:`tpl-fill-body`,children:l.length===0?(0,P.jsx)(`div`,{className:`muted tpl-fill-empty`,children:`这条模板没有参数槽位,可直接进入任务编辑。`}):l.map(e=>(0,P.jsxs)(`label`,{className:`tpl-fill-field`,children:[(0,P.jsx)(`span`,{className:`tpl-fill-label`,children:e}),(0,P.jsx)(`textarea`,{className:`tpl-fill-input`,value:u[e]??``,placeholder:`填写「${e}」(可留空)`,onChange:t=>f(e,t.target.value),rows:4})]},e))}),(0,P.jsxs)(`div`,{className:`tpl-fill-foot`,children:[(0,P.jsxs)(c,{variant:`secondary`,onClick:()=>p(!1),children:[(0,P.jsx)(e,{name:`edit`,size:13}),` 进入编辑页(草稿)`]}),(0,P.jsxs)(c,{variant:`primary`,onClick:()=>p(!0),children:[(0,P.jsx)(e,{name:`check`,size:13}),` 直接提交`]})]})]})}function H({config:n}){let r=s(),i=t(),a=r.tpl,o=(0,N.useMemo)(()=>j(n?.id),[n?.id]),l=C(o?{topic:o.topic||``,group:o.group||``,repo:o.repo||``}:{topic:`__no_topic__`}),[u,d]=(0,N.useState)(``),[f,p]=(0,N.useState)(null),[m,h]=(0,N.useState)(null),[v,x]=(0,N.useState)(null),[S,w]=(0,N.useState)(!1),T=l.templates||[],E=_(T,u,e=>[e.name,e.body,(e.scope||[]).join(` `),k(e.body).join(` `)]),D=async(e,t)=>{if(!S){w(!0);try{await e(),t&&i(t)}catch(e){i(String(e.message||e))}finally{w(!1)}}},O=async(e,t)=>{if(e===t)return;let n=T.map(e=>e.id),r=n.indexOf(e),i=n.indexOf(t);r<0||i<0||(n.splice(r,1),n.splice(i,0,e),await D(()=>a.reorder(n)))},A=()=>{let e=o?.group?[`group:${o.group}`]:o?.repo?[`repo:${o.repo}`]:o?.topic?[`topic:${o.topic}`]:[];b(async()=>{let{openTemplateEditor:e}=await import(`./index-CMjG5NVU.js`).then(e=>e.i);return{openTemplateEditor:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])).then(({openTemplateEditor:t})=>{r.model&&t(r.model,{mode:`new`,scope:e,topic:o?.topic||``,name:``})})},M=o?.label||o?.topic||o?.group||o?.repo||`本主题`;return(0,P.jsxs)(`div`,{className:`rp-page tpl-mng-page`,children:[(0,P.jsx)(y,{}),(0,P.jsxs)(`div`,{className:`page-head`,children:[(0,P.jsxs)(`div`,{className:`title-block`,children:[(0,P.jsxs)(`h2`,{children:[(0,P.jsx)(e,{name:`gear`,size:16}),` 管理模板 · `,M]}),(0,P.jsx)(`p`,{className:`muted tpl-head-note`,children:`只显示本主题可见的模板。拖动左侧把手调整顺序,点图标改可见范围;搜索框会同步隐藏不匹配的行。`})]}),(0,P.jsx)(`div`,{className:`acts`,children:(0,P.jsxs)(c,{variant:`primary`,small:!0,disabled:S,onClick:A,children:[(0,P.jsx)(e,{name:`plus`,size:13}),` 新建模板`]})})]}),(0,P.jsx)(`div`,{className:`tpl-mng-search`,children:(0,P.jsx)(g,{value:u,onChange:d,placeholder:`搜索名称 / 正文 / 槽位 / 可见范围…`,title:`过滤本主题模板`,count:E.length,className:`wide`})}),T.length?(0,P.jsx)(`div`,{className:`tpl-mng-list`,children:E.map(t=>{let n=t.id===a?.defaultId,i=k(t.body);return(0,P.jsxs)(`div`,{className:[`tpl-mng-row`,f===t.id?`is-dragging`:``,m===t.id&&f!==t.id?`is-over`:``].filter(Boolean).join(` `),draggable:!0,onDragStart:e=>{p(t.id),e.dataTransfer.effectAllowed=`move`},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,h(t.id)},onDrop:e=>{e.preventDefault(),h(null),f&&O(f,t.id),p(null)},onDragEnd:()=>{p(null),h(null)},children:[(0,P.jsx)(`span`,{className:`tpl-mng-grip`,title:`拖动排序`,children:(0,P.jsx)(e,{name:`grip`,size:14})}),(0,P.jsxs)(`div`,{className:`tpl-mng-main`,children:[(0,P.jsxs)(`div`,{className:`tpl-mng-line`,children:[(0,P.jsx)(`span`,{className:`tpl-mng-name`,children:t.name}),n&&(0,P.jsx)(`span`,{className:`tpl-badge`,children:`默认`}),t.builtin&&(0,P.jsx)(`span`,{className:`tpl-badge soft`,children:`内置`}),i.length>0&&(0,P.jsxs)(`span`,{className:`tpl-badge soft`,children:[`槽位 `,i.length]})]}),(t.scope||[]).length>0&&!v&&(0,P.jsxs)(`div`,{className:`tpl-mng-scope-sum muted`,children:[`可见:`,(t.scope||[]).join(` / `)]})]}),(0,P.jsxs)(`div`,{className:`tpl-mng-acts`,children:[(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`可见范围`,onClick:()=>x(v===t.id?null:t.id),children:(0,P.jsx)(e,{name:`globe`,size:14})}),(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`编辑`,onClick:()=>r.onNavigate?.(`#/templates/edit/${encodeURIComponent(t.id)}`),children:(0,P.jsx)(e,{name:`edit`,size:14})}),!n&&(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`设为默认`,disabled:S,onClick:()=>D(()=>a.setDefault(t.id),`默认模板已设为「${t.name}」`),children:(0,P.jsx)(e,{name:`star`,size:14})}),!t.builtin&&(0,P.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`删除`,disabled:S,onClick:()=>D(()=>a.remove(t.id),`已删除「${t.name}」`),children:(0,P.jsx)(e,{name:`trash`,size:14})})]}),v===t.id&&(0,P.jsx)(`div`,{className:`tpl-mng-scope`,children:(0,P.jsx)(R,{scope:t.scope,originTopic:t.originTopic,onChange:e=>a.update(t.id,{scope:e})})})]},t.id)})}):(0,P.jsx)(`div`,{className:`muted`,style:{padding:`8px 2px`},children:`本主题下没有可见模板。`})]})}var U=e=>`tpl:${e||`new`}`,W=/\{\{\s*[^}{\s][^{}]*?\s*\}\}/;function G(e){let t=new Set;return m(e).forEach((e,n)=>{W.test(e)&&t.add(n)}),t}var K=`## 背景
4
-
5
- {{content}}
6
-
7
- ## 验收
8
- - [ ] …
9
-
10
- ## 约束
11
- - …`;function q({templateId:e,initialName:n,initialBody:r,initialValues:i,isNew:a,onSave:o,onClose:s,busy:c}){let m=t(),[g,_]=(0,N.useState)(n||``),[v,b]=(0,N.useState)(r||``),[x,S]=(0,N.useState)(`split`),[C,w]=(0,N.useState)(!1),T=(0,N.useRef)(null),E=(0,N.useRef)(new Map),O=U(a?`new`:e),k=(0,N.useMemo)(()=>u(D(v||``,i)),[v,i]),A=(0,N.useMemo)(()=>G(v||``),[v]),j=A.size,M=(e,t,n=`typing`)=>{f(E.current,O,{title:g,body:v},n),_(e),b(t),w(!0)},F=(e,t=`typing`)=>M(e,v,t),I=(e,t=`op`)=>M(g,e,t),L=()=>{let e=d(E.current,O,{title:g,body:v});e&&(_(e.title||``),b(e.body||``),w(!0))},R=()=>{let e=p(E.current,O,{title:g,body:v});e&&(_(e.title||``),b(e.body||``),w(!0))},z=async()=>{if(!(g||``).trim()){m(`模板名不能为空(标题即名称)`);return}await o({name:g.trim(),body:v}),h(E.current,O),w(!1)};return(0,P.jsx)(`div`,{className:`mdw mdw-tpl-edpage`,"data-mode":x,children:(0,P.jsxs)(`div`,{className:`mdw-main`,children:[(0,P.jsxs)(`div`,{className:`mdw-top`,children:[(0,P.jsx)(y,{}),(0,P.jsxs)(`div`,{className:`mdw-head`,children:[(0,P.jsx)(`div`,{className:`mdw-title`,children:a?`新建模板`:`编辑模板`}),(0,P.jsxs)(`div`,{className:`mdw-path`,children:[`任务模板`,g?` / ${g}`:``,C?` · 未保存`:``]})]})]}),(0,P.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,P.jsxs)(`div`,{className:`mdw-toolbar-left`,children:[(0,P.jsx)(`div`,{className:`seg`,role:`group`,"aria-label":`编辑模式`,children:[{id:`split`,label:`并排`},{id:`edit`,label:`源码`}].map(e=>(0,P.jsx)(`button`,{type:`button`,className:x===e.id?`on`:``,onClick:()=>S(e.id),children:e.label},e.id))}),(0,P.jsx)(`span`,{className:`tpl-slot-hint`+(j?``:` is-none`),title:`插槽只有这一个名字;可以出现多次,共用同一个值`,children:j?(0,P.jsxs)(P.Fragment,{children:[`插槽 `,(0,P.jsx)(`b`,{children:j}),` 处 · `,(0,P.jsx)(`code`,{children:`{{content}}`}),` 可填,其余只读`]}):(0,P.jsxs)(P.Fragment,{children:[`还没有插槽 —— 正文里写 `,(0,P.jsx)(`code`,{children:`{{content}}`}),`,那段在任务里就可填`]})})]}),(0,P.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`模板操作`,children:[(0,P.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:c,onClick:s,children:`关闭`}),(0,P.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:c||!C,onClick:z,children:a?`创建`:`保存`})]})]}),(0,P.jsx)(l,{mode:x,title:g,body:v,previewHtml:k,tplSlotBlocks:A,onTitle:F,onBody:I,docKey:O,editorApiRef:T,onSave:z,onUndo:L,onRedo:R,attachments:[]})]})})}function J({config:e,model:n,tabId:r}){let i=s(),a=i.tpl,c=t(),[l,u]=(0,N.useState)(!1),d=e||{},f=d.mode||(d.id?`edit`:``),p=f===`new`,m=d.id||``;if(f===`fill`)return(0,P.jsx)(V,{config:d});if(f===`manage`)return(0,P.jsx)(H,{config:d});let h=()=>{let e=v();if(e&&i.onNavigate){i.onNavigate(e);return}if(i.onNavigate){i.onNavigate(`#/overview`);return}if(n&&r)try{n.doAction(o.deleteTab(r))}catch{}};if(!a)return(0,P.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,P.jsx)(y,{}),(0,P.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});if(!p&&!m)return(0,P.jsx)(B,{});let g=p?null:(a.templates||[]).find(e=>e.id===m);if(!p&&!g)return(0,P.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,P.jsx)(y,{}),(0,P.jsxs)(`div`,{className:`pad muted`,children:[`找不到模板「`,m,`」——可能已删除。`]})]});let _=async({name:e,body:t})=>{u(!0);try{if(p){let n={};Array.isArray(d.scope)&&(n.scope=d.scope),d.topic&&(n.topic=d.topic),await a.add(e,t,!1,n),c(`已创建模板`)}else await a.update(m,{name:e,body:t}),c(`已保存模板`);h()}catch(e){c(String(e.message||e))}finally{u(!1)}},b=p?d.name||``:g?.name??``,x=p?K:g?.body??``,S=p?null:g?.values??null;return(0,P.jsx)(q,{templateId:m,initialName:b,initialBody:x,initialValues:S,isNew:p,busy:l,onSave:_,onClose:h},p?`new:${d.topic||``}:${(d.scope||[]).join(`,`)}`:m)}export{J as default};
@@ -1 +0,0 @@
1
- .tpl-page{flex-direction:column;gap:12px;display:flex}.tpl-head-note{margin:2px 0 0;font-size:12px}.tpl-head-note code,.tpl-slot-hint code{background:var(--soft,#f1f0ec);border:1px solid var(--line,#e4e2dc);border-radius:4px;padding:0 4px;font:400 11.5px ui-monospace,Consolas,monospace}.tpl-slot-hint{white-space:nowrap;text-overflow:ellipsis;color:var(--mdw-accent,#2f6f5e);margin-left:10px;font-size:11px;overflow:hidden}.tpl-slot-hint b{font-weight:600}.tpl-slot-hint.is-none{color:var(--mid,#8a8578)}.mdw-tpl-edpage .mdw-lp-slot{opacity:1}.mdw-tpl-edpage .mdw-lp-block.is-slot{box-shadow:inset 3px 0 0 var(--mdw-accent-line,#b7d4c8)}.tpl-search{padding:2px 0 8px}.tpl-list{flex-direction:column;gap:8px;min-width:0;display:flex}.tpl-card{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:10px;flex-direction:column;gap:6px;min-width:0;padding:10px 12px;display:flex}.tpl-card.is-default{border-color:var(--mdw-accent-line,#b7d4c8)}.tpl-card-head{flex-wrap:wrap;align-items:center;gap:8px;min-width:0;display:flex}.tpl-card-name{font-size:13px;font-weight:600}.tpl-badge{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e);border:1px solid var(--mdw-accent-line,#b7d4c8);border-radius:999px;padding:0 6px;font-size:10.5px;line-height:1.7}.tpl-badge.soft{background:var(--soft,#f1f0ec);color:var(--mid,#8a8578);border-color:var(--line,#e4e2dc)}.tpl-card-slots{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e);border:1px solid var(--mdw-accent-line,#b7d4c8);text-overflow:ellipsis;white-space:nowrap;border-radius:999px;max-width:340px;padding:0 6px;font-size:10.5px;line-height:1.7;overflow:hidden}.tpl-card-grow{flex:auto;min-width:0;max-width:none}.tpl-card-acts{flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:6px;display:flex}.tpl-card-sum{color:var(--ink-2,#4b515a);-webkit-line-clamp:2;-webkit-box-orient:vertical;font-size:11.5px;line-height:1.6;display:-webkit-box;overflow:hidden}.tpl-card-scope{border-top:1px dashed var(--line,#e4e2dc);padding-top:6px}.tpl-preview{border:1px dashed var(--line,#e4e2dc);background:var(--soft,#f7f6f3);border-radius:8px;flex-direction:column;gap:6px;margin-top:2px;padding:9px 11px;display:flex}.tpl-preview-note{color:var(--mid,#8a8578);font-size:10.5px}.tpl-preview-body{min-width:0;max-height:300px;overflow:auto}.tpl-card-hint{color:var(--mid,#8a8578);font-size:11px;line-height:1.6}.tpl-card-hint code{background:var(--soft,#f1f0ec);border:1px solid var(--line,#e4e2dc);border-radius:3px;padding:0 3px;font:400 10.5px ui-monospace,Consolas,monospace}.tpl-fill-page{gap:12px}.tpl-fill-page .page-head h2{align-items:center;gap:7px;display:flex}.tpl-fill-body{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:10px;flex-direction:column;gap:14px;min-width:0;max-width:720px;padding:14px;display:flex}.tpl-fill-field{flex-direction:column;gap:6px;min-width:0;display:flex}.tpl-fill-label{color:var(--ink-2,#4b515a);font-size:12px;font-weight:600}.tpl-fill-input{resize:vertical;box-sizing:border-box;width:100%;min-height:84px;color:var(--ink,#222);background:var(--paper,#fff);border:1px solid var(--line,#e4e2dc);border-radius:8px;padding:8px 10px;font:400 12.5px/1.6 inherit}.tpl-fill-input:focus{border-color:var(--mdw-accent-line,#b7d4c8);outline:none}.tpl-fill-empty{padding:8px 0}.tpl-fill-foot{justify-content:flex-end;gap:8px;max-width:720px;display:flex}.tpl-mng-page{gap:12px}.tpl-mng-page .page-head h2{align-items:center;gap:7px;display:flex}.tpl-mng-search{padding:2px 0 6px}.tpl-mng-list{flex-direction:column;gap:6px;min-width:0;display:flex}.tpl-mng-row{border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);border-radius:9px;grid-template-columns:22px minmax(0,1fr) auto;align-items:center;gap:8px;padding:8px 10px;display:grid}.tpl-mng-row.is-dragging{opacity:.5}.tpl-mng-row.is-over{border-color:var(--mdw-accent,#2f6f5e);box-shadow:inset 0 -2px 0 var(--mdw-accent,#2f6f5e)}.tpl-mng-grip{cursor:grab;color:var(--mid,#8a8578);justify-content:center;align-items:center;display:flex}.tpl-mng-grip:active{cursor:grabbing}.tpl-mng-main{min-width:0}.tpl-mng-line{flex-wrap:wrap;align-items:center;gap:6px;min-width:0;display:flex}.tpl-mng-name{color:var(--ink,#222);font-size:12.5px;font-weight:600}.tpl-mng-scope-sum{text-overflow:ellipsis;white-space:nowrap;margin-top:3px;font-size:10.5px;overflow:hidden}.tpl-mng-acts{align-items:center;gap:2px;display:flex}.tpl-mng-scope{border-top:1px dashed var(--line,#e4e2dc);grid-column:1/-1;padding-top:8px}.tpl-badge.slot{align-items:center;gap:3px;display:inline-flex}.tpl-card .iconbtn.is-on{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e)}.tpl-page .page-head h2,.tpl-mng-page .page-head h2{align-items:center;gap:7px;display:flex}