nx-kv 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/package.json +1 -1
  3. package/src/modules/bundled/index.js +34 -15
  4. package/src/modules/bundled/service.js +32 -2
  5. package/src/modules/localtask/index.js +16 -1
  6. package/src/modules/localtask/store-io.js +10 -1
  7. package/src/modules/localtask/task-lifecycle.js +24 -0
  8. package/src/modules/localtask/task-templates.js +17 -0
  9. package/src/modules/localtask/topics.js +8 -3
  10. package/src/modules/tasktool/attach.js +50 -14
  11. package/src/modules/tasktool/delivery-template.js +20 -2
  12. package/src/modules/tasktool/preview.js +1 -0
  13. package/src/modules/tasktool/wait.js +46 -8
  14. package/src/shared/feedback-text.js +57 -0
  15. package/src/web/frontend/App.jsx +3 -10
  16. package/src/web/frontend/components/layout/breadcrumb.jsx +1 -1
  17. package/src/web/frontend/components/layout/crumbs.js +15 -15
  18. package/src/web/frontend/components/md/tool-bar.jsx +39 -152
  19. package/src/web/frontend/modules/board/reopen-text.js +17 -17
  20. package/src/web/frontend/modules/md/style.css +18 -36
  21. package/src/web/frontend/page/dir/index.jsx +40 -14
  22. package/src/web/frontend/page/dir/task.jsx +116 -60
  23. package/src/web/frontend/page/settings/prompts-section.jsx +214 -5
  24. package/src/web/frontend/page/settings/style.css +13 -0
  25. package/src/web/public/assets/{Introduction-ka0UxW_S.js → Introduction-vTffOL-5.js} +1 -1
  26. package/src/web/public/assets/{cloud-y1mZIdlN.js → cloud-truDniwE.js} +1 -1
  27. package/src/web/public/assets/{dag-CiMSs7uT.js → dag-BPV2Yvmk.js} +1 -1
  28. package/src/web/public/assets/{dir-DKzzrY8P.js → dir-Cmrrc252.js} +3 -3
  29. package/src/web/public/assets/{group-DOLdLkaj.js → group-B26fV4Ec.js} +1 -1
  30. package/src/web/public/assets/{index-CbZfbzqr.js → index-CFkF2w23.js} +2 -2
  31. package/src/web/public/assets/index-DUxHMjZA.css +1 -0
  32. package/src/web/public/assets/{md-edit-ops-Bl0Zx0aJ.js → md-edit-ops-BIXUZ5BM.js} +1 -1
  33. package/src/web/public/assets/md-history-BLnTGoI5.js +5 -0
  34. package/src/web/public/assets/{member-picker-Dsy1GH0E.js → member-picker-CNGyhd0r.js} +1 -1
  35. package/src/web/public/assets/{overview-ty9m-bCh.js → overview-CRPbHHGF.js} +1 -1
  36. package/src/web/public/assets/{progress-BQJhISlF.js → progress-CNgMymPb.js} +1 -1
  37. package/src/web/public/assets/reopen-text-DIFfS71D.js +6 -0
  38. package/src/web/public/assets/{repos-Di5InllN.js → repos-CPSsUWZ5.js} +1 -1
  39. package/src/web/public/assets/route-crumb-DTo_wUoT.js +1 -0
  40. package/src/web/public/assets/settings-BQ3gTrIV.js +12 -0
  41. package/src/web/public/assets/{settings-CRK86fnJ.css → settings-knWtG9Kc.css} +1 -1
  42. package/src/web/public/assets/task-D_7iKWwt.js +7 -0
  43. package/src/web/public/assets/{template-slots-D40ponA2.js → template-slots-Bc70bnzR.js} +1 -1
  44. package/src/web/public/assets/{templates-Ca1jXhnO.js → templates-ChQO154-.js} +1 -1
  45. package/src/web/public/assets/{upload-BeiJetbd.js → upload-CzUtsVcG.js} +1 -1
  46. package/src/web/public/index.html +2 -2
  47. package/src/web/public/assets/index-DUvCgdUV.css +0 -1
  48. package/src/web/public/assets/md-history-Ddk04A_2.js +0 -5
  49. package/src/web/public/assets/reopen-text-DSB76_rF.js +0 -5
  50. package/src/web/public/assets/route-crumb-g3leiQhY.js +0 -1
  51. package/src/web/public/assets/settings-CE-rlcXr.js +0 -8
  52. package/src/web/public/assets/task-D97dEZdc.js +0 -6
@@ -1,4 +1,4 @@
1
- import{d as e,f as t,h as n,l as r,o as i,r as a,u as ee}from"./attach-v8BxRJ7p.js";import{K as o,S as s,W as c,v as l}from"./index-CbZfbzqr.js";import{t as u}from"./route-crumb-g3leiQhY.js";import{a as d,o as f}from"./md-history-Ddk04A_2.js";import{r as p}from"./Introduction-ka0UxW_S.js";import{t as te}from"./member-picker-Dsy1GH0E.js";var m=n(t(),1),h=e(),g={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function _({onClose:e,onChanged:t,repos:n,boards:i}){let a=r(),s=ee(),[c,l]=(0,m.useState)(`import`),[u,d]=(0,m.useState)({}),[f,p]=(0,m.useState)({}),[te,_]=(0,m.useState)(!1),[v,ne]=(0,m.useState)(``),[y,re]=(0,m.useState)(``),[b,x]=(0,m.useState)(null),[S,C]=(0,m.useState)({}),[w,T]=(0,m.useState)({}),[ie,E]=(0,m.useState)(`ours`),[ae,D]=(0,m.useState)(`none`),[O,oe]=(0,m.useState)(``),[k,A]=(0,m.useState)(null),[j,M]=(0,m.useState)(!1),N=(0,m.useMemo)(()=>n||[],[n]),se=(0,m.useMemo)(()=>N.map(e=>e.key),[N]),ce=(0,m.useMemo)(()=>(i||[]).map(e=>e.name),[i]),P=e=>{let t={};for(let n of se)t[n]=e;d(t)},le=e=>{let t={};for(let n of ce)t[n]=e;p(t)},F=()=>{let e={};for(let t of se)e[t]=!u[t];d(e)},ue=()=>a(async()=>{let e=Object.keys(u).filter(e=>u[e]),t=Object.keys(f).filter(e=>f[e]),n={repos:e.length&&e.length!==se.length?e:void 0,boards:t.length&&t.length!==ce.length?t.map(e=>`board/${e}`):void 0,noUnassigned:te},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),te&&r.set(`no-unassigned`,`1`);let i=await o(`/api/repos/export`+(r.toString()?`?`+r:``));ne(JSON.stringify(i,null,2)),s(`已生成布局:${i.repos.length} 个仓库 / ${i.boards.length} 个看板`)}),de=()=>{if(!v)return;let e=new Blob([v],{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)},I=async e=>{let t=e.target.files?.[0];t&&(re(await t.text()),x(null),A(null))},fe=()=>a(async()=>{if(y.trim()){M(!0);try{let e=await o(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});x(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;C(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;T(n),A(null),s(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{M(!1)}}}),pe=()=>a(async()=>{let e=Object.keys(S).filter(e=>S[e]),n=Object.keys(w).filter(e=>w[e]);M(!0);try{let r=await o(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:ie,clone:ae,selection:e.length?e:void 0,boards:n.length?n:void 0}});A(r),s(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await L(),t&&await t()}finally{M(!1)}}),L=(0,m.useCallback)(async()=>{try{let e=await o(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});x(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;C(t)}catch{}},[y]),R=(0,m.useMemo)(()=>b?O?b.repos.filter(e=>e.status===O):b.repos:[],[b,O]),me=(e,n)=>a(async()=>{if(n){M(!0);try{await o(`/api/repos/clone`,{method:`POST`,body:{remote:n,key:e,type:`ref`,depth:1}}),s(`已克隆: ${e}`),await L(),t&&await t()}finally{M(!1)}}}),he=e=>{let t={...S};for(let n of R)t[n.key]=e;C(t)};(0,m.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(t.stopImmediatePropagation(),e())};return document.addEventListener(`keydown`,t,!0),()=>document.removeEventListener(`keydown`,t,!0)},[e]);let z=(0,m.useMemo)(()=>{if(!b)return null;let e={new:0,changed:0,same:0};for(let t of b.repos)e[t.status]=(e[t.status]||0)+1;return e},[b]);return(0,h.jsx)(`div`,{className:`rp-full`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,h.jsxs)(`div`,{className:`rp-full-box`,children:[(0,h.jsxs)(`div`,{className:`rp-full-head`,children:[(0,h.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,h.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,h.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,h.jsx)(`button`,{className:`rp-tab`+(c===`import`?` on`:``),onClick:()=>l(`import`),children:`导入`}),(0,h.jsx)(`button`,{className:`rp-tab`+(c===`export`?` on`:``),onClick:()=>l(`export`),children:`导出`})]}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:e,children:`关闭`})]}),c===`export`?(0,h.jsxs)(`div`,{className:`rp-full-body`,children:[(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,h.jsx)(`span`,{children:`导出范围`}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>P(!0),children:`全选仓库`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>P(!1),children:`全不选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:F,children:`反选`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-sel`,children:[N.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!u[e.key],onChange:t=>d(n=>({...n,[e.key]:t.target.checked}))}),(0,h.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,h.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),N.length?null:(0,h.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,h.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,h.jsx)(`span`,{children:`看板`}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>le(!0),children:`全选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>le(!1),children:`全不选`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-sel`,children:[(i||[]).map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!f[e.name],onChange:t=>p(n=>({...n,[e.name]:t.target.checked}))}),(0,h.jsx)(`span`,{children:e.name})]},e.name)),i?.length?null:(0,h.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,h.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:te,onChange:e=>_(e.target.checked)}),(0,h.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn`,onClick:ue,children:`生成布局`}),(0,h.jsx)(`button`,{className:`btn ghost`,disabled:!v,onClick:de,children:`下载 JSON`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`导出结果`})}),(0,h.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:v,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,h.jsxs)(`div`,{className:`rp-full-body`,children:[(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`导入来源`})}),(0,h.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:I}),(0,h.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{re(e.target.value),x(null)}}),(0,h.jsx)(`div`,{className:`form-acts`,children:(0,h.jsx)(`button`,{className:`btn`,disabled:!y.trim()||j,onClick:fe,children:`差异检查`})}),b?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,h.jsx)(`span`,{children:`冲突方案`})}),(0,h.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,h.jsx)(`input`,{type:`radio`,name:`strategy`,checked:ie===e,onChange:()=>E(e)}),(0,h.jsx)(`span`,{children:t})]},e))}),(0,h.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,h.jsx)(`span`,{children:`克隆`})}),(0,h.jsxs)(`select`,{value:ae,onChange:e=>D(e.target.value),children:[(0,h.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,h.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,h.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,h.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,h.jsx)(`div`,{className:`form-acts`,children:(0,h.jsxs)(`button`,{className:`btn`,disabled:j,onClick:pe,children:[`执行导入(已选 `,Object.values(S).filter(Boolean).length,`)`]})})]}):null,k?(0,h.jsxs)(`div`,{className:`rp-import-result`,children:[(0,h.jsxs)(`div`,{children:[`新建 `,k.created.length,` · 覆盖 `,k.updated.length,` · 另存 `,k.duplicated.length,` · 跳过 `,k.skipped.length]}),(0,h.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,k.boardsCreated,` / 合并 `,k.boardsMerged,` · 参考关系 `,k.links]}),k.cloned.length?(0,h.jsxs)(`div`,{children:[`克隆 `,k.cloned.length,` 个`]}):null,k.unmatched.length?(0,h.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,k.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,h.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:b?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,h.jsxs)(`span`,{children:[`差异(新增 `,z.new,` · 有差异 `,z.changed,` · 一致 `,z.same,b.summary.missing?` · 本地未拥有 ${b.summary.missing}`:``,`)`]}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`rp-chip`+(O===``?` on`:``),onClick:()=>oe(``),children:`全部`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`new`?` on`:``),onClick:()=>oe(`new`),children:`新增`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`changed`?` on`:``),onClick:()=>oe(`changed`),children:`有差异`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`same`?` on`:``),onClick:()=>oe(`same`),children:`一致`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>he(!0),children:`全选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>he(!1),children:`全不选`})]})]}),(0,h.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,h.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{style:{width:`32px`}}),(0,h.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,h.jsx)(`th`,{children:`仓库 key`}),(0,h.jsx)(`th`,{children:`差异字段`})]})}),(0,h.jsxs)(`tbody`,{children:[R.map(e=>(0,h.jsxs)(`tr`,{className:`rp-diff-row `+g[e.status]?.cls,children:[(0,h.jsx)(`td`,{children:(0,h.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!S[e.key],onChange:t=>C(n=>({...n,[e.key]:t.target.checked}))})}),(0,h.jsx)(`td`,{children:(0,h.jsx)(`span`,{className:`rp-status `+g[e.status]?.cls,children:g[e.status]?.label})}),(0,h.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,h.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,h.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:j,onClick:()=>me(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,h.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`b`,{children:e.field}),`: `,(0,h.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,h.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,h.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),b.missing.map(e=>(0,h.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,h.jsx)(`td`,{}),(0,h.jsx)(`td`,{children:(0,h.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,h.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,h.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),b.boards.length?(0,h.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`看板`})}),b.boards.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!w[e.key],onChange:t=>T(n=>({...n,[e.key]:t.target.checked}))}),(0,h.jsx)(`span`,{className:`rp-status `+g[e.status]?.cls,children:g[e.status]?.label}),(0,h.jsx)(`span`,{children:e.key}),(0,h.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),b.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,h.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,h.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,h.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,h.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,h.jsx)(`button`,{className:`btn small`,disabled:j,onClick:()=>me(e.key,e.remote),children:`克隆到本地`}):(0,h.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,h.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}function v(e,t){let n=[],r=e.descDocs||null;if(t){let r=(e.boards||[]).find(e=>e.id===t.id),i=r&&r.noteDocRel||``,a=r&&r.noteDocPath||``,ee=a?`path:`+a:i?`rel:`+i:``;ee&&n.push({id:ee,kind:`group`,label:`组内描述`,sub:`「${t.name}」里 ${e.name} 的角色`,note:r&&r.note||``,writable:!a})}let i=r&&r.main;i&&i.docId&&n.push({id:i.docId,kind:`main`,label:i.title||`项目主篇`,sub:i.rel||i.path||``,note:i.summary||``,exists:!!i.exists,writable:!i.path});for(let e of r&&r.links||[])e.docId&&n.push({id:e.docId,kind:`link`,label:e.title||e.docId,sub:e.tag?`#`+e.tag:``,note:e.note||``,writable:String(e.docId).startsWith(`rel:`)});return n}function ne({repo:e,board:t,onClose:n,onSaved:r,onOpenTab:i}){let c=ee(),u=(0,m.useMemo)(()=>v(e,t),[e,t]),[p,te]=(0,m.useState)(()=>u[0]?u[0].id:``),[g,_]=(0,m.useState)(null),[ne,y]=(0,m.useState)(!1),[re,b]=(0,m.useState)(`split`),[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(``),T=(0,m.useRef)(null),ie=u.find(e=>e.id===p)||null,E=(0,m.useCallback)(async e=>{if(!e){_(null);return}w(``);try{let t=await o(`/api/docs/item?ref=`+encodeURIComponent(e));_(t),y(!1)}catch(e){w(String(e.message||e)),_(null)}},[]);(0,m.useEffect)(()=>{E(p)},[p,E]);let ae=e=>{y(!0),_(t=>t&&{...t,body:e,title:s(e,t.title)})},D=e=>{y(!0),_(t=>{if(!t)return t;let n=/^#\s+/m.test(t.body)?t.body.replace(/^#\s+.+$/m,`# ${e||`未命名文档`}`):`# ${e||`未命名文档`}\n\n${t.body}`;return{...t,body:n,title:e}})},O=(0,m.useCallback)(async()=>{if(!g||!g.writable||x)return!0;S(!0),w(``);try{let e=g.missing?await o(`/api/docs/item`,{method:`POST`,body:{rel:g.rel,body:g.body}}):await o(`/api/docs/item`,{method:`PATCH`,body:{ref:p,body:g.body}});return _(t=>t&&{...t,missing:!1,summary:e&&e.summary}),y(!1),c&&c(`描述已保存`),r&&r(),!0}catch(e){return w(String(e.message||e)),!1}finally{S(!1)}},[g,x,p,c,r]),oe=async e=>{e!==p&&(ne&&g&&g.writable&&!await O()||te(e))},k=!!(g&&g.writable),A=(0,m.useMemo)(()=>g?l(g.body,[]):``,[g]);return(0,h.jsx)(a,{size:`wide`,title:`描述 · ${e.name}${t?` @「${t.name}」`:``}`,onClose:async()=>{ne&&g&&g.writable&&await O(),n()},children:(0,h.jsxs)(`div`,{className:`rpd`,children:[(0,h.jsxs)(`div`,{className:`rpd-list`,children:[u.length===0?(0,h.jsx)(`div`,{className:`rpd-none`,children:`这个仓库还没有描述文档`}):null,u.map(e=>{let t=e.kind===`link`||!!(e.note||e.exists);return(0,h.jsxs)(`button`,{type:`button`,className:`rpd-item`+(e.id===p?` on`:``),onClick:()=>oe(e.id),title:e.sub||e.label,children:[(0,h.jsxs)(`span`,{className:`rpd-item-top`,children:[(0,h.jsx)(`span`,{className:`rpd-item-label`,children:e.label}),e.kind===`group`?(0,h.jsx)(`span`,{className:`rpd-badge`,children:`组内`}):null,e.kind===`link`&&e.sub?(0,h.jsx)(`span`,{className:`rpd-badge`,children:e.sub}):null,t?null:(0,h.jsx)(`span`,{className:`rpd-todo`,children:`未写`})]}),e.note?(0,h.jsx)(`span`,{className:`rpd-item-note`,children:e.note}):null]},e.id)})]}),(0,h.jsxs)(`div`,{className:`rpd-main`,children:[(0,h.jsxs)(`div`,{className:`rpd-bar`,children:[(0,h.jsx)(`span`,{className:`rpd-path mono`,title:g?g.rel||g.path:``,children:g?g.rel||g.path:ie?ie.sub:``}),ne?(0,h.jsx)(`span`,{className:`rpd-dirty`,children:`未保存`}):null,g&&!k?(0,h.jsx)(`span`,{className:`rpd-badge`,children:`外部 · 只读`}):null,(0,h.jsx)(`span`,{className:`grow`}),k?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f,{mode:re,onChange:b}),(0,h.jsx)(`button`,{type:`button`,className:`btn small`,disabled:x||!ne,onClick:O,children:x?`保存中…`:`保存`})]}):null,i&&g?(0,h.jsx)(`button`,{type:`button`,className:`btn small ghost`,title:`在文档页签里打开(读全文 / 点双链跳转)`,onClick:()=>{i(p),n()},children:`↗ 页签`}):null]}),C?(0,h.jsx)(`div`,{className:`rpd-err`,children:C}):null,g?(0,h.jsx)(`div`,{className:`rpd-body`,children:(0,h.jsx)(d,{mode:k?re:`preview`,title:g.title,body:g.body,previewHtml:A,onTitle:k?D:null,onBody:k?ae:null,attachments:[],docKey:p,editorApiRef:T,onSave:k?O:null})}):(0,h.jsx)(`div`,{className:`rpd-empty`,children:C?``:`选择左侧的一篇描述开始编辑`})]})]})})}var y={path:``,name:``,desc:``,notes:``,type:`dev`,remote:``};function re({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,h.jsx)(c,{text:t,children:t}):(0,h.jsxs)(c,{text:t,title:`点击复制完整路径`,children:[(0,h.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function b({docs:e,onOpen:t,tip:n=``}){let r=e&&e.main,i=e&&e.links||[];if(!r||!r.title)return null;let a=[n,`主篇:${r.rel||r.path}`,...i.map(e=>(e.tag?`[${e.tag}] `:``)+e.title+(e.note?` —— ${e.note}`:``))].filter(Boolean).join(`
1
+ import{d as e,f as t,h as n,l as r,o as i,r as a,u as ee}from"./attach-v8BxRJ7p.js";import{K as o,S as s,W as c,v as l}from"./index-CFkF2w23.js";import{t as u}from"./route-crumb-DTo_wUoT.js";import{a as d,o as f}from"./md-history-BLnTGoI5.js";import{r as p}from"./Introduction-vTffOL-5.js";import{t as te}from"./member-picker-CNGyhd0r.js";var m=n(t(),1),h=e(),g={new:{label:`新增`,cls:`new`},changed:{label:`有差异`,cls:`changed`},same:{label:`一致`,cls:`same`}};function _({onClose:e,onChanged:t,repos:n,boards:i}){let a=r(),s=ee(),[c,l]=(0,m.useState)(`import`),[u,d]=(0,m.useState)({}),[f,p]=(0,m.useState)({}),[te,_]=(0,m.useState)(!1),[v,ne]=(0,m.useState)(``),[y,re]=(0,m.useState)(``),[b,x]=(0,m.useState)(null),[S,C]=(0,m.useState)({}),[w,T]=(0,m.useState)({}),[ie,E]=(0,m.useState)(`ours`),[ae,D]=(0,m.useState)(`none`),[O,oe]=(0,m.useState)(``),[k,A]=(0,m.useState)(null),[j,M]=(0,m.useState)(!1),N=(0,m.useMemo)(()=>n||[],[n]),se=(0,m.useMemo)(()=>N.map(e=>e.key),[N]),ce=(0,m.useMemo)(()=>(i||[]).map(e=>e.name),[i]),P=e=>{let t={};for(let n of se)t[n]=e;d(t)},le=e=>{let t={};for(let n of ce)t[n]=e;p(t)},F=()=>{let e={};for(let t of se)e[t]=!u[t];d(e)},ue=()=>a(async()=>{let e=Object.keys(u).filter(e=>u[e]),t=Object.keys(f).filter(e=>f[e]),n={repos:e.length&&e.length!==se.length?e:void 0,boards:t.length&&t.length!==ce.length?t.map(e=>`board/${e}`):void 0,noUnassigned:te},r=new URLSearchParams;n.repos?.length&&r.set(`repos`,n.repos.join(`,`)),n.boards?.length&&r.set(`boards`,n.boards.join(`,`)),te&&r.set(`no-unassigned`,`1`);let i=await o(`/api/repos/export`+(r.toString()?`?`+r:``));ne(JSON.stringify(i,null,2)),s(`已生成布局:${i.repos.length} 个仓库 / ${i.boards.length} 个看板`)}),de=()=>{if(!v)return;let e=new Blob([v],{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)},I=async e=>{let t=e.target.files?.[0];t&&(re(await t.text()),x(null),A(null))},fe=()=>a(async()=>{if(y.trim()){M(!0);try{let e=await o(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});x(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;C(t);let n={};for(let t of e.boards)n[t.key]=t.status!==`same`;T(n),A(null),s(`差异:新增 ${e.summary.new} · 有差异 ${e.summary.changed} · 一致 ${e.summary.same} · 本地未拥有 ${e.summary.missing}`)}finally{M(!1)}}}),pe=()=>a(async()=>{let e=Object.keys(S).filter(e=>S[e]),n=Object.keys(w).filter(e=>w[e]);M(!0);try{let r=await o(`/api/repos/import`,{method:`POST`,body:{json:y,strategy:ie,clone:ae,selection:e.length?e:void 0,boards:n.length?n:void 0}});A(r),s(`导入完成:新建 ${r.created.length} · 覆盖 ${r.updated.length} · 另存 ${r.duplicated.length}`),await L(),t&&await t()}finally{M(!1)}}),L=(0,m.useCallback)(async()=>{try{let e=await o(`/api/repos/import/diff`,{method:`POST`,body:{json:y}});x(e);let t={};for(let n of e.repos)t[n.key]=n.status!==`same`;C(t)}catch{}},[y]),R=(0,m.useMemo)(()=>b?O?b.repos.filter(e=>e.status===O):b.repos:[],[b,O]),me=(e,n)=>a(async()=>{if(n){M(!0);try{await o(`/api/repos/clone`,{method:`POST`,body:{remote:n,key:e,type:`ref`,depth:1}}),s(`已克隆: ${e}`),await L(),t&&await t()}finally{M(!1)}}}),he=e=>{let t={...S};for(let n of R)t[n.key]=e;C(t)};(0,m.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(t.stopImmediatePropagation(),e())};return document.addEventListener(`keydown`,t,!0),()=>document.removeEventListener(`keydown`,t,!0)},[e]);let z=(0,m.useMemo)(()=>{if(!b)return null;let e={new:0,changed:0,same:0};for(let t of b.repos)e[t.status]=(e[t.status]||0)+1;return e},[b]);return(0,h.jsx)(`div`,{className:`rp-full`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,h.jsxs)(`div`,{className:`rp-full-box`,children:[(0,h.jsxs)(`div`,{className:`rp-full-head`,children:[(0,h.jsxs)(`div`,{className:`rp-full-title`,children:[`导入导出`,(0,h.jsx)(`span`,{className:`muted`,children:`以全局 key 为身份 · 不含本地路径 · 逐条选择与冲突方案`})]}),(0,h.jsxs)(`div`,{className:`rp-full-tabs`,children:[(0,h.jsx)(`button`,{className:`rp-tab`+(c===`import`?` on`:``),onClick:()=>l(`import`),children:`导入`}),(0,h.jsx)(`button`,{className:`rp-tab`+(c===`export`?` on`:``),onClick:()=>l(`export`),children:`导出`})]}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:e,children:`关闭`})]}),c===`export`?(0,h.jsxs)(`div`,{className:`rp-full-body`,children:[(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,h.jsx)(`span`,{children:`导出范围`}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>P(!0),children:`全选仓库`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>P(!1),children:`全不选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:F,children:`反选`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-sel`,children:[N.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!u[e.key],onChange:t=>d(n=>({...n,[e.key]:t.target.checked}))}),(0,h.jsx)(`span`,{className:e.type===`ref`?`rp-full-tag-ref`:``,children:e.name}),(0,h.jsx)(`span`,{className:`muted rp-full-key`,title:e.key,children:e.key})]},e.key)),N.length?null:(0,h.jsx)(`div`,{className:`muted`,children:`还没有仓库`})]}),(0,h.jsxs)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:[(0,h.jsx)(`span`,{children:`看板`}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>le(!0),children:`全选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>le(!1),children:`全不选`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-sel`,children:[(i||[]).map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!f[e.name],onChange:t=>p(n=>({...n,[e.name]:t.target.checked}))}),(0,h.jsx)(`span`,{children:e.name})]},e.name)),i?.length?null:(0,h.jsx)(`div`,{className:`muted`,children:`还没有看板`})]}),(0,h.jsxs)(`label`,{className:`rp-pick-item`,style:{marginTop:10},children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:te,onChange:e=>_(e.target.checked)}),(0,h.jsx)(`span`,{children:`不带未分组的仓库`})]}),(0,h.jsxs)(`div`,{className:`form-acts`,children:[(0,h.jsx)(`button`,{className:`btn`,onClick:ue,children:`生成布局`}),(0,h.jsx)(`button`,{className:`btn ghost`,disabled:!v,onClick:de,children:`下载 JSON`})]})]}),(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`导出结果`})}),(0,h.jsx)(`textarea`,{className:`rp-full-out`,readOnly:!0,value:v,spellCheck:`false`,placeholder:`点「生成布局」后在这里预览 JSON(可直接复制或下载)`})]})]}):(0,h.jsxs)(`div`,{className:`rp-full-body`,children:[(0,h.jsxs)(`div`,{className:`rp-full-col`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`导入来源`})}),(0,h.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:I}),(0,h.jsx)(`textarea`,{className:`rp-full-input`,rows:7,spellCheck:`false`,placeholder:`粘贴布局 JSON,或选一个 .json 文件`,value:y,onChange:e=>{re(e.target.value),x(null)}}),(0,h.jsx)(`div`,{className:`form-acts`,children:(0,h.jsx)(`button`,{className:`btn`,disabled:!y.trim()||j,onClick:fe,children:`差异检查`})}),b?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:12},children:(0,h.jsx)(`span`,{children:`冲突方案`})}),(0,h.jsx)(`div`,{className:`rp-strategy`,children:[[`ours`,`保留本地`,`本地已有的不动,只新建缺失的`],[`overwrite`,`强制覆盖`,`用导入文件覆盖本地字段(key 不变)`],[`duplicate`,`另存新 key`,`为冲突项新建 key-import-1/2/3,两条并存`]].map(([e,t,n])=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,title:n,children:[(0,h.jsx)(`input`,{type:`radio`,name:`strategy`,checked:ie===e,onChange:()=>E(e)}),(0,h.jsx)(`span`,{children:t})]},e))}),(0,h.jsx)(`div`,{className:`rp-full-colhead`,style:{marginTop:10},children:(0,h.jsx)(`span`,{children:`克隆`})}),(0,h.jsxs)(`select`,{value:ae,onChange:e=>D(e.target.value),children:[(0,h.jsx)(`option`,{value:`none`,children:`不克隆,只登记`}),(0,h.jsx)(`option`,{value:`ref`,children:`克隆参考仓库`}),(0,h.jsx)(`option`,{value:`dev`,children:`克隆开发仓库`}),(0,h.jsx)(`option`,{value:`all`,children:`全部克隆`})]}),(0,h.jsx)(`div`,{className:`form-acts`,children:(0,h.jsxs)(`button`,{className:`btn`,disabled:j,onClick:pe,children:[`执行导入(已选 `,Object.values(S).filter(Boolean).length,`)`]})})]}):null,k?(0,h.jsxs)(`div`,{className:`rp-import-result`,children:[(0,h.jsxs)(`div`,{children:[`新建 `,k.created.length,` · 覆盖 `,k.updated.length,` · 另存 `,k.duplicated.length,` · 跳过 `,k.skipped.length]}),(0,h.jsxs)(`div`,{className:`muted`,children:[`看板 新建 `,k.boardsCreated,` / 合并 `,k.boardsMerged,` · 参考关系 `,k.links]}),k.cloned.length?(0,h.jsxs)(`div`,{children:[`克隆 `,k.cloned.length,` 个`]}):null,k.unmatched.length?(0,h.jsxs)(`div`,{className:`rp-layout-warn`,children:[`本地未拥有 `,k.unmatched.length,` 条(见下方差异表)`]}):null]}):null]}),(0,h.jsx)(`div`,{className:`rp-full-col rp-full-col-wide`,children:b?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`rp-full-colhead`,children:[(0,h.jsxs)(`span`,{children:[`差异(新增 `,z.new,` · 有差异 `,z.changed,` · 一致 `,z.same,b.summary.missing?` · 本地未拥有 ${b.summary.missing}`:``,`)`]}),(0,h.jsxs)(`span`,{className:`acts`,children:[(0,h.jsx)(`button`,{className:`rp-chip`+(O===``?` on`:``),onClick:()=>oe(``),children:`全部`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`new`?` on`:``),onClick:()=>oe(`new`),children:`新增`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`changed`?` on`:``),onClick:()=>oe(`changed`),children:`有差异`}),(0,h.jsx)(`button`,{className:`rp-chip`+(O===`same`?` on`:``),onClick:()=>oe(`same`),children:`一致`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>he(!0),children:`全选`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>he(!1),children:`全不选`})]})]}),(0,h.jsx)(`div`,{className:`rp-diff-table-wrap`,children:(0,h.jsxs)(`table`,{className:`rp-diff-table`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{style:{width:`32px`}}),(0,h.jsx)(`th`,{style:{width:`90px`},children:`状态`}),(0,h.jsx)(`th`,{children:`仓库 key`}),(0,h.jsx)(`th`,{children:`差异字段`})]})}),(0,h.jsxs)(`tbody`,{children:[R.map(e=>(0,h.jsxs)(`tr`,{className:`rp-diff-row `+g[e.status]?.cls,children:[(0,h.jsx)(`td`,{children:(0,h.jsx)(`input`,{type:`checkbox`,disabled:e.status===`same`,checked:!!S[e.key],onChange:t=>C(n=>({...n,[e.key]:t.target.checked}))})}),(0,h.jsx)(`td`,{children:(0,h.jsx)(`span`,{className:`rp-status `+g[e.status]?.cls,children:g[e.status]?.label})}),(0,h.jsxs)(`td`,{className:`mono rp-diff-key`,children:[e.key,e.status===`new`&&e.canClone?(0,h.jsx)(`span`,{className:`rp-can-clone`,title:`导入时可克隆`,children:`可克隆`}):null,e.status===`new`&&e.canClone?(0,h.jsx)(`button`,{className:`btn small ghost rp-clone-btn`,title:`现在就克隆到本地(用这个 key 登记 → 组里的占位自动补齐)`,disabled:j,onClick:()=>me(e.key,e.incoming?.remote||``),children:`克隆到本地`}):null]}),(0,h.jsx)(`td`,{className:`rp-diff-fields`,children:e.fields.length?e.fields.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`b`,{children:e.field}),`: `,(0,h.jsx)(`span`,{className:`rp-was`,children:JSON.stringify(e.local)}),` → `,(0,h.jsx)(`span`,{className:`rp-now`,children:JSON.stringify(e.incoming)})]},e.field)):(0,h.jsx)(`span`,{className:`muted`,children:`—`})})]},e.key)),b.missing.map(e=>(0,h.jsxs)(`tr`,{className:`rp-diff-row missing`,children:[(0,h.jsx)(`td`,{}),(0,h.jsx)(`td`,{children:(0,h.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`})}),(0,h.jsx)(`td`,{className:`mono rp-diff-key`,children:e}),(0,h.jsx)(`td`,{className:`rp-diff-fields muted`,children:`文件里被引用,但文件与本地都没有定义`})]},`miss-`+e))]})]})}),b.boards.length?(0,h.jsxs)(`div`,{className:`rp-diff-boards`,children:[(0,h.jsx)(`div`,{className:`rp-full-colhead`,children:(0,h.jsx)(`span`,{children:`看板`})}),b.boards.map(e=>(0,h.jsxs)(`label`,{className:`rp-pick-item`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:!!w[e.key],onChange:t=>T(n=>({...n,[e.key]:t.target.checked}))}),(0,h.jsx)(`span`,{className:`rp-status `+g[e.status]?.cls,children:g[e.status]?.label}),(0,h.jsx)(`span`,{children:e.key}),(0,h.jsxs)(`span`,{className:`muted`,children:[`(`,e.incoming.repos.length,` 个成员`,e.missingMembers.length?`,本地未拥有 ${e.missingMembers.length}`:``,`)`]})]},e.key)),b.boards.flatMap(e=>e.missingMembers||[]).map(e=>(0,h.jsxs)(`div`,{className:`rp-missing-item`,children:[(0,h.jsx)(`span`,{className:`rp-status missing`,children:`本地未拥有`}),(0,h.jsx)(`span`,{className:`mono rp-missing-key`,children:e.key}),e.remote?(0,h.jsx)(`span`,{className:`muted rp-missing-remote`,title:e.remote,children:e.remote}):null,e.clonable?(0,h.jsx)(`button`,{className:`btn small`,disabled:j,onClick:()=>me(e.key,e.remote),children:`克隆到本地`}):(0,h.jsx)(`span`,{className:`muted`,title:`没有远程地址 —— 自行创建后用 repo key set 指定同一个 key`,children:`需手工创建`})]},e.key))]}):null]}):(0,h.jsx)(`div`,{className:`muted rp-full-empty`,children:`粘贴或选择一份布局 JSON,点「差异检查」后在这里逐条查看与勾选。`})})]})]})})}function v(e,t){let n=[],r=e.descDocs||null;if(t){let r=(e.boards||[]).find(e=>e.id===t.id),i=r&&r.noteDocRel||``,a=r&&r.noteDocPath||``,ee=a?`path:`+a:i?`rel:`+i:``;ee&&n.push({id:ee,kind:`group`,label:`组内描述`,sub:`「${t.name}」里 ${e.name} 的角色`,note:r&&r.note||``,writable:!a})}let i=r&&r.main;i&&i.docId&&n.push({id:i.docId,kind:`main`,label:i.title||`项目主篇`,sub:i.rel||i.path||``,note:i.summary||``,exists:!!i.exists,writable:!i.path});for(let e of r&&r.links||[])e.docId&&n.push({id:e.docId,kind:`link`,label:e.title||e.docId,sub:e.tag?`#`+e.tag:``,note:e.note||``,writable:String(e.docId).startsWith(`rel:`)});return n}function ne({repo:e,board:t,onClose:n,onSaved:r,onOpenTab:i}){let c=ee(),u=(0,m.useMemo)(()=>v(e,t),[e,t]),[p,te]=(0,m.useState)(()=>u[0]?u[0].id:``),[g,_]=(0,m.useState)(null),[ne,y]=(0,m.useState)(!1),[re,b]=(0,m.useState)(`split`),[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(``),T=(0,m.useRef)(null),ie=u.find(e=>e.id===p)||null,E=(0,m.useCallback)(async e=>{if(!e){_(null);return}w(``);try{let t=await o(`/api/docs/item?ref=`+encodeURIComponent(e));_(t),y(!1)}catch(e){w(String(e.message||e)),_(null)}},[]);(0,m.useEffect)(()=>{E(p)},[p,E]);let ae=e=>{y(!0),_(t=>t&&{...t,body:e,title:s(e,t.title)})},D=e=>{y(!0),_(t=>{if(!t)return t;let n=/^#\s+/m.test(t.body)?t.body.replace(/^#\s+.+$/m,`# ${e||`未命名文档`}`):`# ${e||`未命名文档`}\n\n${t.body}`;return{...t,body:n,title:e}})},O=(0,m.useCallback)(async()=>{if(!g||!g.writable||x)return!0;S(!0),w(``);try{let e=g.missing?await o(`/api/docs/item`,{method:`POST`,body:{rel:g.rel,body:g.body}}):await o(`/api/docs/item`,{method:`PATCH`,body:{ref:p,body:g.body}});return _(t=>t&&{...t,missing:!1,summary:e&&e.summary}),y(!1),c&&c(`描述已保存`),r&&r(),!0}catch(e){return w(String(e.message||e)),!1}finally{S(!1)}},[g,x,p,c,r]),oe=async e=>{e!==p&&(ne&&g&&g.writable&&!await O()||te(e))},k=!!(g&&g.writable),A=(0,m.useMemo)(()=>g?l(g.body,[]):``,[g]);return(0,h.jsx)(a,{size:`wide`,title:`描述 · ${e.name}${t?` @「${t.name}」`:``}`,onClose:async()=>{ne&&g&&g.writable&&await O(),n()},children:(0,h.jsxs)(`div`,{className:`rpd`,children:[(0,h.jsxs)(`div`,{className:`rpd-list`,children:[u.length===0?(0,h.jsx)(`div`,{className:`rpd-none`,children:`这个仓库还没有描述文档`}):null,u.map(e=>{let t=e.kind===`link`||!!(e.note||e.exists);return(0,h.jsxs)(`button`,{type:`button`,className:`rpd-item`+(e.id===p?` on`:``),onClick:()=>oe(e.id),title:e.sub||e.label,children:[(0,h.jsxs)(`span`,{className:`rpd-item-top`,children:[(0,h.jsx)(`span`,{className:`rpd-item-label`,children:e.label}),e.kind===`group`?(0,h.jsx)(`span`,{className:`rpd-badge`,children:`组内`}):null,e.kind===`link`&&e.sub?(0,h.jsx)(`span`,{className:`rpd-badge`,children:e.sub}):null,t?null:(0,h.jsx)(`span`,{className:`rpd-todo`,children:`未写`})]}),e.note?(0,h.jsx)(`span`,{className:`rpd-item-note`,children:e.note}):null]},e.id)})]}),(0,h.jsxs)(`div`,{className:`rpd-main`,children:[(0,h.jsxs)(`div`,{className:`rpd-bar`,children:[(0,h.jsx)(`span`,{className:`rpd-path mono`,title:g?g.rel||g.path:``,children:g?g.rel||g.path:ie?ie.sub:``}),ne?(0,h.jsx)(`span`,{className:`rpd-dirty`,children:`未保存`}):null,g&&!k?(0,h.jsx)(`span`,{className:`rpd-badge`,children:`外部 · 只读`}):null,(0,h.jsx)(`span`,{className:`grow`}),k?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(f,{mode:re,onChange:b}),(0,h.jsx)(`button`,{type:`button`,className:`btn small`,disabled:x||!ne,onClick:O,children:x?`保存中…`:`保存`})]}):null,i&&g?(0,h.jsx)(`button`,{type:`button`,className:`btn small ghost`,title:`在文档页签里打开(读全文 / 点双链跳转)`,onClick:()=>{i(p),n()},children:`↗ 页签`}):null]}),C?(0,h.jsx)(`div`,{className:`rpd-err`,children:C}):null,g?(0,h.jsx)(`div`,{className:`rpd-body`,children:(0,h.jsx)(d,{mode:k?re:`preview`,title:g.title,body:g.body,previewHtml:A,onTitle:k?D:null,onBody:k?ae:null,attachments:[],docKey:p,editorApiRef:T,onSave:k?O:null})}):(0,h.jsx)(`div`,{className:`rpd-empty`,children:C?``:`选择左侧的一篇描述开始编辑`})]})]})})}var y={path:``,name:``,desc:``,notes:``,type:`dev`,remote:``};function re({path:e}){let t=String(e||``),n=t.replace(/\\/g,`/`).lastIndexOf(`/`);return n<0?(0,h.jsx)(c,{text:t,children:t}):(0,h.jsxs)(c,{text:t,title:`点击复制完整路径`,children:[(0,h.jsx)(`span`,{className:`anc`,children:t.slice(0,n)}),t.slice(n)]})}function b({docs:e,onOpen:t,tip:n=``}){let r=e&&e.main,i=e&&e.links||[];if(!r||!r.title)return null;let a=[n,`主篇:${r.rel||r.path}`,...i.map(e=>(e.tag?`[${e.tag}] `:``)+e.title+(e.note?` —— ${e.note}`:``))].filter(Boolean).join(`
2
2
  `);return(0,h.jsxs)(`div`,{className:`rp-desc`,children:[(0,h.jsx)(`button`,{type:`button`,className:`rp-doc`+(r.exists?``:` ghost`),title:a||`打开项目介绍文档`,onClick:()=>t(r),children:(0,h.jsx)(`span`,{className:`rp-doc-tx`,children:r.exists?r.summary||r.title:`未写`})}),i.length?(0,h.jsxs)(`span`,{className:`rp-doc-more`,title:`另有 ${i.length} 篇补充文档`,children:[`+`,i.length]}):null]})}function x({r:e,filterBoard:t,refsOfRepo:n,acts:r}){let i=t?(e.boards||[]).find(e=>e.id===t.id)?.note||``:null,a=n.get(e.key)||[];return(0,h.jsxs)(`tr`,{children:[(0,h.jsxs)(`td`,{className:`rp-name`,children:[(0,h.jsxs)(`strong`,{children:[e.icon?(0,h.jsx)(`span`,{className:`rp-icon`,"aria-hidden":!0,children:e.icon}):null,e.name]}),(0,h.jsx)(b,{docs:e.descDocs,onOpen:r.doc,tip:i?`组内描述:${i}`:``})]}),(0,h.jsx)(`td`,{className:`mono rp-path`,children:(0,h.jsx)(re,{path:e.path})}),(0,h.jsxs)(`td`,{className:`rp-refs`,children:[a.length?a.map(t=>(0,h.jsxs)(`button`,{className:`rp-ref-chip`,title:`直接绑定:${t.remote||``}${t.note?`
3
3
  `+t.note:``}\n点击改绑定描述`,onClick:()=>r.refNote(t,e),children:[t.note?(0,h.jsx)(`span`,{className:`rp-ref-chip-dot`}):null,t.name]},t.key)):(0,h.jsx)(`span`,{className:`muted rp-refs-none`,children:`—`}),(0,h.jsx)(`button`,{className:`btn small ghost rp-ref-bind`,title:`管理这个仓库绑定的参考仓库`,onClick:()=>r.bind(e),children:`绑定`})]}),(0,h.jsxs)(`td`,{className:`rp-acts`,children:[(0,h.jsx)(`button`,{className:`btn small ghost`,title:`在文件管理器中打开`,onClick:()=>r.open(e),children:`打开`}),(0,h.jsx)(`button`,{className:`btn small ghost`,title:`对齐 remote:列出 git remote -v 的候选并检查远端是否存在`,onClick:()=>r.remote(e),children:`remote`}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>r.edit(e),children:`编辑`}),t?(0,h.jsx)(`button`,{className:`btn small ghost`,title:`打开「${e.name}」在「${t.name}」里的组内描述文档`,onClick:()=>r.note(e),children:`描述`}):null,(0,h.jsx)(`button`,{className:`btn small ghost rp-del`,onClick:()=>r.del(e),children:`删除`})]})]})}function S(){let e=r(),t=ee(),{dialog:n,node:s}=i(),{openByDocId:l}=p(),[d,f]=(0,m.useState)(y),[g,v]=(0,m.useState)(null),[re,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(null),[T,ie]=(0,m.useState)(null),[E,ae]=(0,m.useState)(``),[D,O]=(0,m.useState)(null),[oe,k]=(0,m.useState)(!1),[A,j]=(0,m.useState)(``),[M,N]=(0,m.useState)(null),[se,ce]=(0,m.useState)(!1),[P,le]=(0,m.useState)([]),F=e=>t=>f(n=>({...n,[e]:t.target.value})),[ue,de]=(0,m.useState)(!1),[I,fe]=(0,m.useState)(null),[pe,L]=(0,m.useState)(!1),[R,me]=(0,m.useState)({gitRepoRoot:``,gitDevRoot:``}),[he,z]=(0,m.useState)(!1),[B,ge]=(0,m.useState)({url:``,name:``,desc:``,depth:`1`}),[_e,V]=(0,m.useState)({}),[ve,ye]=(0,m.useState)(null),[be,xe]=(0,m.useState)(null),[Se,Ce]=(0,m.useState)({}),[H,we]=(0,m.useState)(null),[Te,Ee]=(0,m.useState)({}),[De,Oe]=(0,m.useState)(null),[U,ke]=(0,m.useState)(null),[Ae,je]=(0,m.useState)(``),[Me,Ne]=(0,m.useState)(!1),[W,Pe]=(0,m.useState)(null),[G,Fe]=(0,m.useState)(null),[Ie,Le]=(0,m.useState)(!1),Re=()=>{f(y),v(null),S(!1)},K=(0,m.useCallback)(async()=>{le(await o(`/api/repos`).catch(()=>[])||[])},[]),q=(0,m.useCallback)(async()=>{ie(await o(`/api/boards`).catch(()=>null))},[]);(0,m.useEffect)(()=>{K(),q()},[K,q]),(0,m.useEffect)(()=>{let e=()=>{let e=location.hash.split(`?`)[1]||``;if(!e)return;let t=new URLSearchParams(e),n=t.get(`board`);n&&(ae(n),t.get(`add`)&&w(n))};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let ze=(0,m.useCallback)(async()=>{fe(await o(`/api/setting`).catch(()=>null))},[]),J=(0,m.useCallback)(async()=>{ye(await o(`/api/repos/ref/check`).catch(()=>null))},[]);(0,m.useEffect)(()=>{ze(),J()},[ze,J]);let Be=()=>e(async()=>{let e={};R.gitRepoRoot.trim()&&(e.gitRepoRoot=R.gitRepoRoot.trim()),R.gitDevRoot.trim()&&(e.gitDevRoot=R.gitDevRoot.trim()),Object.keys(e).length&&(fe(await o(`/api/setting`,{method:`POST`,body:e})),L(!1),t(`已保存存储根目录`))}),Ve=()=>e(async()=>{let e=B.url.trim();if(!e)return;let n={url:e,name:B.name.trim()||void 0,desc:B.desc.trim()||void 0,depth:parseInt(B.depth,10)||1,"no-bind":!0},r=X.filter(e=>_e[`repo:`+e.id]).map(e=>e.id),i=Y.filter(e=>_e[`board:`+e.id]).map(e=>e.id);r.length&&(n.bind=r),i.length&&(n.board=i);let a=await o(`/api/repos/ref/clone`,{method:`POST`,body:n});z(!1),ge({url:``,name:``,desc:``,depth:`1`}),V({}),t(`已克隆: ${a.name} → ${a.dest||a.path}`),await Promise.all([K(),q(),J()])}),He=n=>e(async()=>{let e=await o(`/api/repos/ref/sync`,{method:`POST`,body:{id:n.id}});t(e.status===`updated`?`已更新: ${e.name}`:e.status===`upToDate`?`${e.name} 已是最新`:`${e.name}: ${e.status} ${e.output||``}`)}),Ue=()=>e(async()=>{let e=await o(`/api/repos/ref/sync`,{method:`POST`,body:{all:!0}}),n=e.results.filter(e=>e.status!==`updated`&&e.status!==`upToDate`);t(`同步 ${e.synced} 个${n.length?`,${n.length} 个有问题(见检查结果)`:`,全部完成`}`),await J()}),We=e=>{let t={};for(let n of e.linked||[])t[n.kind+`:`+n.id]=!0;Ce(t),xe(e)},Ge=()=>e(async()=>{if(!be)return;let e=new Set((be.linked||[]).map(e=>e.kind+`:`+e.id)),t=new Set(Object.keys(Se).filter(e=>Se[e]));for(let n of t){if(e.has(n))continue;let[t,r]=n.split(`:`);await o(`/api/repos/bind`,{method:`POST`,body:{id:be.key,[t]:[r]}})}for(let n of e){if(t.has(n))continue;let[e,r]=n.split(`:`);await o(`/api/repos/bind`,{method:`POST`,body:{id:be.key,[e]:[r],remove:!0}})}xe(null),await Promise.all([K(),J()])}),Ke=()=>e(async()=>{if(!H)return;let e=new Set;for(let t of H.linked||[])t.kind===`ref`&&e.add(t.id);for(let t of Z)(t.linked||[]).some(e=>e.kind===`repo`&&e.id===H.key)&&e.add(t.key);let t=new Set(Object.keys(Te).filter(e=>Te[e]));for(let n of t)e.has(n)||await o(`/api/repos/bind`,{method:`POST`,body:{id:n,repo:[H.key]}});for(let n of e)t.has(n)||await o(`/api/repos/bind`,{method:`POST`,body:{id:n,repo:[H.key],remove:!0}});we(null),await Promise.all([K(),J()])}),qe=(e,t,n,r)=>{let i=(e.linked||[]).find(e=>e.kind===t&&e.id===n);ke({ref:e,kind:t,targetId:n,targetName:r}),je(i?.note||``)},Je=()=>e(async()=>{let{ref:e,kind:n,targetId:r}=U;await o(`/api/repos/ref/note`,{method:`POST`,body:{id:e.key,[n]:r,note:Ae}}),ke(null),await Promise.all([K(),J()]),t(`已保存绑定描述`)}),Ye=(t,n,r)=>e(async()=>{await o(`/api/repos/bind`,{method:`POST`,body:{id:t.key,[n]:[r],remove:!0}}),await Promise.all([K(),J()])}),Xe=(0,m.useCallback)(async()=>{await Promise.all([K(),q(),J()])},[K,q,J]),Ze=async e=>{let n=e&&e.key?e.key:``;if(!n){t(`这个仓库还没有 key —— 先 nx-kv repo key set <id> <key>`);return}try{let e=await o(`/api/repos/remote/list?id=`+encodeURIComponent(n));if(!e||!Array.isArray(e.remotes))throw Error(`远程地址读取失败`);Pe(e),Fe(null),Le(!0)}catch(e){t(String(e&&e.message||e))}},Qe=n=>e(async()=>{await o(`/api/repos/remote/pick`,{method:`POST`,body:{id:W.key,url:n}}),Le(!1),t(`已对齐 remote`),await Promise.all([K(),J()])}),$e=async e=>{let t=W?W.key:``;if(!t){Fe({url:``,status:`unreachable`,detail:`没有仓库标识`});return}Fe({url:e||W.current||``,status:`checking`,detail:`检查中…`});try{let n=await o(`/api/repos/remote/check?id=`+encodeURIComponent(t)+(e?`&url=`+encodeURIComponent(e):``));Fe(n)}catch(t){Fe({url:e||W.current||``,status:`unreachable`,detail:String(t&&t.message||t)})}},Y=(0,m.useMemo)(()=>T&&T.boards||[],[T]),X=(0,m.useMemo)(()=>P.filter(e=>(e.type||`dev`)!==`ref`),[P]),Z=(0,m.useMemo)(()=>P.filter(e=>e.type===`ref`),[P]),et=(0,m.useMemo)(()=>E?X.filter(e=>(e.boards||[]).some(e=>e.id===E)):X,[X,E]),Q=(0,m.useMemo)(()=>Y.find(e=>e.id===E)||null,[Y,E]),tt=(0,m.useMemo)(()=>Y.find(e=>e.id===C)||null,[Y,C]),nt=(0,m.useMemo)(()=>{let e=new Map;return(ve?.refs||[]).forEach(t=>e.set(t.id,t)),e},[ve]),rt=(0,m.useMemo)(()=>{let e=new Map,t=(t,n,r)=>{e.has(t)||e.set(t,[]),e.get(t).push({key:n.key,id:n.id,name:n.name,remote:n.remote||``,note:r||``})},n=new Map(Z.map(e=>[e.key,e])),r=new Set;for(let e of X)for(let i of e.linked||[]){if(i.kind!==`ref`)continue;let a=n.get(i.id);a&&(r.add(e.key+`:`+a.key),t(e.key,a,i.note))}for(let e of Z)for(let n of e.linked||[])n.kind===`repo`&&(r.has(n.id+`:`+e.key)||t(n.id,e,n.note));return e},[X,Z]),it=(0,m.useMemo)(()=>{if(!Q)return[];let e=new Set((Q.repos||[]).map(e=>e.key)),t=Q.key||`board/${Q.name}`;return Z.map(n=>{let r=(n.linked||[]).find(e=>e.kind===`board`&&e.id===t),i=(n.linked||[]).filter(t=>t.kind===`repo`&&e.has(t.id));return!r&&!i.length?null:{...n,boardNote:r?.note||``,viaRepos:i.map(e=>(Q.repos||[]).find(t=>t.key===e.id)?.name||e.id)}}).filter(Boolean)},[Z,Q]),at=()=>{f(y),v(null),S(!0)},ot=(0,m.useMemo)(()=>{if(!g)return null;let e=P.find(e=>e.id===g);return e&&e.descDocs||null},[g,P]),st=()=>e(async()=>{if(!d.path.trim())return;let e={path:d.path.trim(),name:d.name.trim()||void 0,notes:d.notes,type:d.type===`ref`?`ref`:`dev`,remote:d.remote.trim()||void 0};g?await o(`/api/repos/${encodeURIComponent(g)}`,{method:`PATCH`,body:e}):await o(`/api/repos`,{method:`POST`,body:e}),Re(),await Promise.all([K(),q(),J()])}),$=(t,r)=>e(async()=>{if(t===`open`)await o(`/api/repos/open`,{method:`POST`,body:{id:r.id}});else if(t===`edit`)v(r.id),f({path:r.path,name:r.name||``,desc:r.desc||``,type:r.type||`dev`,remote:r.remote||``,notes:r.notes||``}),S(!0);else if(t===`del`){if(!await n({message:`删除仓库登记「${r.name}」?(仅移除登记,磁盘文件不受影响;各看板里的归属同步摘除)`,danger:!0}))return;await o(`/api/repos/${encodeURIComponent(r.id)}`,{method:`DELETE`}),await Promise.all([K(),q(),J()])}}),ct=()=>e(async()=>{let e={name:D.name.trim()};e.name&&(D.id||(e.desc=D.desc.trim()||void 0),D.id?await o(`/api/boards/${encodeURIComponent(D.id)}`,{method:`PATCH`,body:e}):await o(`/api/boards`,{method:`POST`,body:e}),O(null),await q())}),lt=t=>e(async()=>{await n({message:`删看板「${t.name}」?它里面的 ${t.repos.length} 个仓库**仍留在中心清单里**(只是少了一份归属)。`,danger:!0})&&(await o(`/api/boards/${encodeURIComponent(t.id)}`,{method:`DELETE`,body:{}}),await Promise.all([K(),q()]))}),ut=()=>e(async()=>{if(!A.trim())return;let e=await o(`/api/boards/import`,{method:`POST`,body:{json:A}});k(!1),j(``),t(`已导入:新建 ${e.created} 个看板、合并 ${e.merged} 个、匹配仓库 ${e.matched} 个`+(e.unmatched.length?`;未匹配 ${e.unmatched.length} 条(见 CLI board import 输出)`:``)),await Promise.all([K(),q()])}),dt=()=>e(async()=>{let e=await o(`/api/boards/export`);N(JSON.stringify(e,null,2))}),ft=async e=>{let t=e.target.files?.[0];t&&j(await t.text())},pt=(0,m.useMemo)(()=>{let e=new Map;for(let t of[...X,...Z]){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 t=[];for(let n of T&&T.boards||[])for(let r of n.repos||[]){if(r.present!==!1)continue;let i=String(r.key||``).split(`/`).filter(Boolean).pop()||``,a=e.get(String(r.name||``).toLowerCase())||e.get(i.toLowerCase())||null;t.push({...r,board:n.name,boardId:n.id,match:a})}return t},[T,X,Z]);if(T===null)return(0,h.jsxs)(`div`,{className:`rp-page`,children:[(0,h.jsx)(u,{}),(0,h.jsx)(`div`,{className:`muted`,style:{padding:20},children:`读取中…`}),s]});let mt=n=>e(async()=>{await o(`/api/repos/clone`,{method:`POST`,body:{remote:n.remote,key:n.key,name:n.name||void 0,type:`dev`}}),t(`已克隆并登记:${n.name||n.key}`),K(),q()}),ht=(n,r)=>e(async()=>{await o(`/api/boards/rekey`,{method:`POST`,body:{from:n.key,to:r}}),t(`已把「${n.name||n.key}」这个位置接到本机仓库`),K(),q()}),gt=r=>e(async()=>{let e=await n({title:`把「${r.name||r.key}」接到哪个本机仓库?`,input:!0,placeholder:`本机仓库:id / key / 名称 / 绝对路径`});e&&(await o(`/api/boards/rekey`,{method:`POST`,body:{from:r.key,to:e}}),t(`已重绑——这个位置现在指向本机仓库`),K(),q())}),_t=n=>e(async()=>{confirm(`把「${n.name||n.key}」从组「${n.board}」里移除?\n\n只摘这个组里的位置:本机仓库与看板本身都不动。`)&&(await o(`/api/boards/assign`,{method:`POST`,body:{key:n.key,board:n.boardId,remove:!0}}),t(`已从组「${n.board}」移除`),q())}),vt=()=>e(async()=>{let e=await o(`/api/boards/prune`,{method:`POST`,body:{apply:!1}});if(!e?.total){t(`没有可清理的占位(有远程地址的那些留着等 clone)`);return}let n=e.items.map(e=>`· ${e.name}(组 ${e.board})`).join(`
4
4
  `);confirm(`清理 ${e.total} 个无来源占位?\n\n${n}\n\n它们没有远程地址,克隆不回来,只能删。`)&&(await o(`/api/boards/prune`,{method:`POST`,body:{apply:!0}}),t(`已清理 ${e.total} 个占位`),q())}),yt=(t,n)=>e(async()=>{t&&(await o(`/api/docs/item`,{method:`POST`,body:{rel:t,body:`# ${n||t}\n\n`}}).catch(()=>{}),l(`rel:`+t),K())}),bt={open:e=>$(`open`,e),edit:e=>$(`edit`,e),del:e=>$(`del`,e),remote:e=>Ze(e),doc:e=>{if(e&&e.docId)return e.exists||!e.rel?l(e.docId):yt(e.rel,e.title)},bind:e=>{let t={};for(let n of e.linked||[])n.kind===`ref`&&(t[n.id]=!0);for(let n of Z)t[n.key]||(n.linked||[]).some(t=>t.kind===`repo`&&t.id===e.key)&&(t[n.key]=!0);Ee(t),we(e)},refNote:(e,t)=>{let n=Z.find(t=>t.key===e.key);n&&qe(n,`repo`,t.key,t.name)},note:e=>{Oe({repo:e,board:Q||null})}};return(0,h.jsxs)(`div`,{className:`rp-page`,children:[(0,h.jsxs)(`div`,{className:`page-head`,children:[(0,h.jsx)(`div`,{className:`title-block`,children:(0,h.jsx)(`h2`,{children:`仓库`})}),(0,h.jsx)(`div`,{className:`acts`,children:(0,h.jsx)(`button`,{className:`btn`,onClick:at,children:`添加仓库`})})]}),(0,h.jsxs)(`div`,{className:`rp-filters`,"data-testid":`rp-filters`,children:[(0,h.jsxs)(`div`,{className:`rp-filters-main`,children:[(0,h.jsxs)(`button`,{className:`rp-chip`+(E?``:` on`),onClick:()=>ae(``),title:`显示全部开发仓库`,children:[`开发仓库 `,(0,h.jsx)(`b`,{children:X.length})]}),Y.map(e=>(0,h.jsxs)(`button`,{className:`rp-chip`+(E===e.id?` on`:``),onClick:()=>ae(E===e.id?``:e.id),title:`只看「${e.name}」里的仓库(${e.repos.length} 个)`,children:[e.name,` `,(0,h.jsx)(`b`,{children:e.repos.length})]},e.id))]}),(0,h.jsxs)(`div`,{className:`rp-filters-side`,children:[(0,h.jsxs)(`button`,{className:`rp-chip`,onClick:()=>de(!0),title:`弹窗管理参考仓库:克隆 / 绑定 / 同步 / 检查 / 布局导入导出`,children:[`参考仓库 `,(0,h.jsx)(`b`,{children:Z.length}),(0,h.jsx)(`span`,{className:`rp-chip-go`,children:`↗`})]}),(0,h.jsxs)(`button`,{className:`rp-chip`,onClick:()=>ce(!0),title:`弹窗管理看板:新建 / 编辑 / 删除 / 导入 / 导出 / 成员管理`,children:[`看板 `,(0,h.jsx)(`b`,{children:Y.length}),(0,h.jsx)(`span`,{className:`rp-chip-go`,children:`↗`})]})]})]}),pt.length>0&&(0,h.jsxs)(`section`,{className:`rp-pending`,"data-testid":`rp-pending-init`,children:[(0,h.jsxs)(`header`,{className:`rp-pending-head`,children:[(0,h.jsxs)(`div`,{className:`rp-pending-head-main`,children:[(0,h.jsxs)(`h3`,{children:[`待初始化`,(0,h.jsx)(`span`,{className:`rp-pending-count`,children:pt.length})]}),(0,h.jsx)(`p`,{children:`组里有位置、本机没有登记。接到本机仓库、克隆下来,或者直接移除。`})]}),(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:vt,children:`清理无来源占位`})]}),(0,h.jsx)(`div`,{className:`rp-pending-list`,children:pt.map(e=>(0,h.jsxs)(`article`,{className:`rp-pending-card`,children:[(0,h.jsxs)(`div`,{className:`rp-pending-info`,children:[(0,h.jsxs)(`div`,{className:`rp-pending-title`,children:[(0,h.jsx)(`strong`,{children:e.name||e.key}),(0,h.jsxs)(`span`,{className:`rp-pending-board`,children:[`组 · `,e.board]}),e.remote?null:(0,h.jsx)(`span`,{className:`rp-pending-tag`,children:`无远程地址`})]}),(0,h.jsx)(`code`,{className:`rp-pending-key`,children:e.key}),e.desc?(0,h.jsx)(`p`,{className:`rp-pending-desc`,children:e.desc}):null]}),(0,h.jsxs)(`div`,{className:`rp-pending-acts`,children:[e.match?(0,h.jsxs)(`button`,{className:`btn small`,title:`把组里这个位置指向本机仓库「${e.match.name}」(仓库身份不变)`,onClick:()=>ht(e,e.match.id),children:[`绑定到「`,e.match.name,`」`]}):null,e.remote?(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>mt(e),children:`克隆到本地`}):null,(0,h.jsx)(`button`,{className:`btn small ghost`,onClick:()=>gt(e),children:`选本机仓库`}),(0,h.jsx)(`button`,{className:`btn small ghost rp-del`,title:`只从组里摘掉这个位置,本机仓库与看板都不动`,onClick:()=>_t(e),children:`移除`})]})]},e.key+`@`+e.boardId))})]}),Q?(0,h.jsxs)(`div`,{className:`rp-context`,"data-testid":`rp-context`,children:[(0,h.jsx)(`span`,{className:`rp-context-name`,children:Q.name}),Q.desc?(0,h.jsx)(`span`,{className:`rp-context-desc`,title:Q.desc,children:Q.desc}):(0,h.jsx)(`span`,{className:`muted rp-context-desc`,children:`还没有领域描述 —— 点「看板管理」补一句:侧重什么、谁配合谁、关键路径与搜索关键词在哪。`}),(0,h.jsx)(`span`,{className:`acts`,children:(0,h.jsx)(`button`,{className:`btn small`,onClick:()=>w(Q.id),children:`添加成员`})})]}):null,Q?(0,h.jsxs)(`div`,{className:`rp-ref-mounted`,"data-testid":`rp-board-refs`,children:[(0,h.jsxs)(`div`,{className:`rp-ref-mounted-head`,children:[(0,h.jsxs)(`span`,{className:`rp-ref-mounted-label`,children:[`「`,Q.name,`」的参考仓库 `,(0,h.jsx)(`b`,{children:it.length})]}),(0,h.jsx)(`span`,{className:`muted`,children:`组级参考 + 成员仓库各自的参考(多对多:一个参考可同时服务多个组/仓库)`})]}),it.length?it.map(e=>{let t=nt.get(e.id),n=(e.linked||[]).find(e=>e.kind===`board`&&e.id===(Q.key||`board/${Q.name}`));return(0,h.jsxs)(`div`,{className:`rp-ref-mounted-item`,children:[(0,h.jsx)(`span`,{className:`rp-ref-dot`+(t?t.ok?` ok`:` bad`:``),title:t?t.ok?`检查通过`:t.issues.join(`
@@ -0,0 +1 @@
1
+ import{d as e,f as t,h as n}from"./attach-v8BxRJ7p.js";import{U as r,t as i}from"./index-CFkF2w23.js";var a=n(t(),1);function o(e,t={}){if(!e||!e.view)return[];switch(e.view){case`dir`:{let n=[];return t.dirName&&n.push(t.dirName),e.task&&(/^draft/i.test(String(e.task))?n.push(`draft`):n.push(t.pageTitle||`#${e.task}`)),n}case`group`:return t.boardName?[t.boardName]:[`项目组`];case`repos`:return[`仓库管理`];case`cloud`:return[`云端总览`];case`overview`:return[`全部目录总览`];case`templates`:return[`任务模板`];default:return[]}}function s(e){if(!e||!e.view)return``;switch(e.view){case`dir`:return e.task?`#/dir/${encodeURIComponent(e.key||``)}`:`#/overview`;case`group`:return`#/overview`;case`overview`:return``;default:return`#/overview`}}function c(e,t=[],n={}){if(!e)return{boardName:``,dirName:``,pageTitle:``};let r=(n.boards||[]).find(t=>t.id===e.key),i=(t||[]).find(t=>t.key===e.key),a=i&&e.task?(i.tasks||[]).find(t=>String(t.id)===String(e.task)):null;return{boardName:r&&r.name||``,dirName:i?i.name:``,pageTitle:a?`#${a.id}`:``}}var l=e();function u({route:e,ctx:t,onNavigate:n,onBack:r,inline:i=!1}){let c=(0,a.useMemo)(()=>o(e,t),[e,t]),u=(0,a.useMemo)(()=>s(e,t),[e,t]);return c.length?(0,l.jsxs)(`nav`,{className:`nx-crumb`+(i?` nx-crumb-inline`:``),"aria-label":`当前位置`,children:[u&&n?(0,l.jsx)(`button`,{type:`button`,className:`nx-crumb-back`,title:`返回上一级`,"aria-label":`返回上一级`,onClick:()=>r?r():n(u),children:`←`}):null,(0,l.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`[`}),c.map((e,t)=>(0,l.jsxs)(`span`,{className:`nx-crumb-i`,children:[t>0?(0,l.jsx)(`span`,{className:`nx-crumb-sep`,children:`/`}):null,(0,l.jsx)(`span`,{className:`nx-crumb-t`,children:e})]},`${e}-${t}`)),(0,l.jsx)(`span`,{className:`nx-crumb-br`,"aria-hidden":!0,children:`]`})]}):null}function d(){let e=r()||{},t=e.route||{},n=e.rows||[],d=e.repoData||{},f=(0,a.useMemo)(()=>c(t,n,d),[t,n,d]);return(0,a.useMemo)(()=>o(t,f),[t,f]).length?(0,l.jsx)(u,{route:t,ctx:f,onNavigate:e.onNavigate,onBack:()=>{let n=i();if(n&&e.onNavigate){e.onNavigate(n);return}let r=s(t,f);r&&e.onNavigate&&e.onNavigate(r)},inline:!0}):null}export{d as t};
@@ -0,0 +1,12 @@
1
+ import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{A as o,K as s,U as c,a as l,c as u,i as d,n as f,o as p,r as m}from"./index-CFkF2w23.js";import{t as h}from"./template-slots-Bc70bnzR.js";var g=n(t(),1),_=e();function v(e){let t=String(e??``);return t.trim()?t.replace(/\{\{#[^}]*\}\}/g,``).replace(/\{\{\/[^}]*\}\}/g,``).replace(/\{\{[^}]*\}\}/g,``).replace(/「\s*」/g,``).replace(/〔\s*〕/g,``).replace(/\s+/g,` `).trim()||t.replace(/\s+/g,` `).trim():``}function y({value:e,onChange:t,placeholder:n,rows:r=3,sections:i=!1,hint:a=``}){let[o,s]=(0,g.useState)(!1),c=(0,g.useRef)(null),f=(0,g.useRef)(null),p=n=>{let r=c.current,i=r?r.selectionStart:null,a=l(e,n,i);t(a.text),s(!1),requestAnimationFrame(()=>{let e=c.current;if(e){e.focus();try{e.setSelectionRange(a.caret,a.caret)}catch{}}})},h=u(e);return(0,_.jsxs)(`div`,{className:`pp-field`,ref:f,children:[(0,_.jsx)(`textarea`,{ref:c,className:`pp-field-ta mono`,rows:r,value:e,placeholder:n,spellCheck:!1,onChange:e=>t(e.target.value),onBlur:()=>{requestAnimationFrame(()=>{f.current&&f.current.contains(document.activeElement)||s(!1)})}}),(0,_.jsxs)(`div`,{className:`pp-field-bar`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`pp-field-ph-btn`+(o?` on`:``),title:`插入占位符`,onClick:()=>s(e=>!e),children:[`{`,`占位符`,`}`]}),h.length>0&&(0,_.jsx)(`span`,{className:`pp-field-used`,title:`本条用到的占位符`,children:h.map(e=>(0,_.jsx)(`span`,{className:`pp-field-used-chip mono`,children:`{{${e}}}`},e))}),o&&(0,_.jsxs)(`div`,{className:`pp-field-menu`,role:`menu`,children:[m.map(e=>(0,_.jsxs)(`div`,{className:`pp-field-menu-sec`,children:[(0,_.jsx)(`div`,{className:`pp-field-menu-lab`,children:e.label}),e.items.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`pp-field-menu-item`,title:e.desc,onMouseDown:t=>{t.preventDefault(),p(`{{${e.token}}}`)},children:[(0,_.jsx)(`span`,{className:`mono`,children:`{{${e.token}}}`}),(0,_.jsx)(`span`,{className:`pp-field-menu-desc`,children:e.desc})]},e.token))]},e.label)),i&&(0,_.jsxs)(`div`,{className:`pp-field-menu-sec`,children:[(0,_.jsx)(`div`,{className:`pp-field-menu-lab`,children:`段落`}),d.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`pp-field-menu-item`,onMouseDown:t=>{t.preventDefault(),p(e.token)},children:[(0,_.jsx)(`span`,{className:`mono`,children:e.token}),(0,_.jsx)(`span`,{className:`pp-field-menu-desc`,children:e.label})]},e.token))]})]})]}),a?(0,_.jsx)(`div`,{className:`pp-field-hint`,children:a}):null]})}function b({items:e,onChange:t,disabled:n=!1,placeholder:r,rows:i=3,sections:a=!1,hint:o=``,accordion:s=!1,openIndex:c,onOpenChange:l}){let[u,d]=(0,g.useState)(-1),f=c===void 0?u:c,p=e=>{d(e),l&&l(e)},m=(n,r)=>t(e.map((e,t)=>t===n?r:e)),h=n=>{t(e.filter((e,t)=>t!==n)),p(e=>e===n?-1:e>n?e-1:e)};return s?(0,_.jsx)(`div`,{className:`pp-items`,children:e.map((e,t)=>{let o=f===t,s=v(e.split(`
2
+ `)[0]);return(0,_.jsx)(`div`,{className:`pp-items-item`,children:o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(y,{value:e,onChange:e=>m(t,e),placeholder:r,rows:i,sections:a})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>h(t),title:`删除第 ${t+1} 条`,children:`删除`})]}):(0,_.jsxs)(`button`,{type:`button`,className:`pp-items-row`,disabled:n,title:`点击展开编辑`,onClick:()=>p(t),children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`span`,{className:`pp-items-title`,children:s||`(空)`}),(0,_.jsxs)(`span`,{className:`pp-items-len`,children:[String(e).length,` 字`]})]})},t)})}):(0,_.jsx)(_.Fragment,{children:e.map((e,t)=>(0,_.jsxs)(`div`,{className:`pp-items-item`,children:[(0,_.jsx)(`span`,{className:`pp-items-no`,children:t+1}),(0,_.jsx)(`div`,{className:`pp-items-body`,children:(0,_.jsx)(y,{value:e,onChange:e=>m(t,e),placeholder:r,rows:i,sections:a,hint:o})}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:n,onClick:()=>h(t),title:`删除第 ${t+1} 条`,children:`删除`})]},t))})}var x=10,S=[{id:`vars`,label:`变量字典`},{id:`template`,label:`任务模板`},{id:`suffix`,label:`回调提示词`},{id:`ack`,label:`ack 总结`},{id:`attach`,label:`附件提示词`},{id:`delivery`,label:`交付上下文`}];function C({rows:e}){return(0,_.jsx)(`div`,{className:`setp-vars-wrap`,children:(0,_.jsx)(`table`,{children:(0,_.jsx)(`tbody`,{children:e.map(([e,t])=>(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`td`,{children:(0,_.jsx)(`code`,{children:e})}),(0,_.jsx)(`td`,{children:t})]},e))})})})}function w(){return(0,_.jsx)(`div`,{className:`setp-vars-wrap`,children:(0,_.jsxs)(`table`,{children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{children:`模板`}),(0,_.jsx)(`th`,{children:`管什么`}),(0,_.jsx)(`th`,{children:`在哪配`})]})}),(0,_.jsx)(`tbody`,{children:[[`交付上下文`,`任务原文之外的组 / 项目关键路径(介绍、成员、参考文件路径)`,`本页「交付上下文」`],[`回调提示词`,`领取任务后的收尾指令(可多条,按空行拼接)`,`本页「回调提示词」`],[`ack 总结`,`完成任务时写总结的格式要求`,`本页「ack 总结」`],[`附件提示词`,`交付里〔附件〕段的清单与拉取 SOP`,`本页「附件提示词」`],[`任务模板`,`新建任务的正文骨架(槽位填写)`,`本页「任务模板」`],[`持续 get 指令`,`项目开启持续 get 后追加的循环指令`,`项目级设置(侧栏项目 → 持续 get)`],[`任务级 check 指令`,`任务带时间目标(--duration)时的计时 check 要求`,`系统内置:发布时固化,暂不可配`]].map(([e,t,n])=>(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`td`,{children:e}),(0,_.jsx)(`td`,{children:t}),(0,_.jsx)(`td`,{children:n})]},e))})]})})}function T(){return(0,_.jsxs)(`div`,{className:`setp-vars`,children:[(0,_.jsxs)(`div`,{className:`setp-note`,children:[`所有模板共用一套占位符语法(与 Mustache 同形的子集):`,(0,_.jsx)(`code`,{children:`{{var}}`}),` 取值;`,(0,_.jsx)(`code`,{children:`{{#sec}}…{{/sec}}`}),` 是段落闸门——上下文里没有这个键,整段就不出现。 列表类变量(成员、文档、附件清单)是预拼接好的多行文本,写进模板即整块展开。 空壳组(没有任何可交付内容的组)整段不渲染。`]}),(0,_.jsx)(`h4`,{children:`模板清单(都在哪配)`}),(0,_.jsx)(w,{}),(0,_.jsx)(`h4`,{children:`通用变量(所有模板可用)`}),(0,_.jsx)(C,{rows:[[`{{task.id}}`,`任务编号`],[`{{task.text}}`,`任务正文(逐字)。交付模板含它 = 交付自包含原文`],[`{{source}}`,`任务来源:local(本目录队列)/ global(全局共享池)`],[`{{summary}}`,`领取方现状(wait/get --summary)`],[`{{cwd}}`,`工作目录绝对路径`],[`{{name}}`,`目录名`],[`{{params.k}} / {{k}}`,`外部参数(--param k=v 平铺传入;内建同名键不被覆盖)`]]}),(0,_.jsx)(`h4`,{children:`项目 / 组(交付上下文模板)`}),(0,_.jsx)(C,{rows:[[`{{repo.name}} / {{repo.key}}`,`仓库名 / 仓库 key(github.com/owner/repo)`],[`{{repo.intro}} / {{repo.introPath}}`,`项目介绍正文 / 主篇文件路径`],[`{{repo.docs}}`,`项目登记的补充文档清单(多行,可直接读取)`],[`{{#repo}}…{{/repo}}`,`闸门:有项目介绍才出现`],[`{{group.name}} / {{group.desc}}`,`组名 / 组定位(组描述)`],[`{{group.intro}} / {{group.introPath}}`,`组介绍正文 / 主篇路径`],[`{{group.note}}`,`本项目在组里的位置(本仓库的组内描述)`],[`{{group.peers}}`,`组内成员清单(多行:名字 + 组内描述)`],[`{{group.docs}}`,`组绑定参考文件清单(多行,可直接读取)`],[`{{groups}}`,`多组归属时其余组的概览(一行一组)`],[`{{#group}} / {{#groupPeers}} / {{#groupDocs}}`,`闸门:组在 / 有成员 / 有参考文件才出现`]]}),(0,_.jsx)(`h4`,{children:`时间目标(回调 / ack / getLoop 模板)`}),(0,_.jsx)(C,{rows:[[`{{goal.name}}`,`时间目标名`],[`{{goal.deadline}}`,`截止时刻(YYYY-MM-DD HH:mm:ss)`],[`{{goal.prompt}}`,`任务级 check 指令原文(任务带 --duration 时固化)`],[`{{goal.remainingHuman}}`,`人话时间:「剩 12 分钟」/「已超时 3 分钟」`],[`{{goal.remainingSec}} / {{goal.remainingMin}}`,`剩余秒数 / 剩余分钟(向上取整,可做运算比较)`],[`{{goal.overtimeSec}}`,`已超时秒数(未超时 = 0)`],[`{{goal.reached}}`,`是否已到点`],[`{{#goal}}…{{/goal}}`,`闸门:没有时间目标整段消失`]]}),(0,_.jsx)(`h4`,{children:`附件段(附件提示词模板)`}),(0,_.jsx)(C,{rows:[[`{{attach.count}}`,`附件个数`],[`{{attach.list}}`,`附件清单(多行:「- 图片 名: 本地路径 / 图床 id 与拉取命令」)`],[`{{attach.sync}}`,`本次云端同步详情(目录 · 下载 · 跳过 · 失败);空串 = 本次没跑同步`],[`{{#attachSync}}…{{/attachSync}}`,`闸门:本次跑过云端同步才出现`]]})]})}function E(){let e=a(),[t,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(!1),o=(0,g.useCallback)(()=>{s(`/api/localtasks`).then(e=>n(e?.settings?.attachTemplate??``)).catch(t=>e(`读取失败:`+(t.message||t)))},[e]);(0,g.useEffect)(()=>{o()},[o]);let c=async t=>{if(!r){i(!0);try{let r=await s(`/api/localtasks/setting`,{method:`PATCH`,body:{attachTemplate:t??``}});n(r?.attachTemplate??``),e(t&&t.trim()?`已保存附件段提示词`:`已恢复内置默认附件段`)}catch(t){e(String(t.message||t))}finally{i(!1)}}};return(0,_.jsxs)(`div`,{className:`setp-suffix`,children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`附件段提示词(〔附件〕段的清单与拉取 SOP;空 = 内置默认,附件段不能关)`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>c(t),disabled:r||t===null,children:`保存`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>c(``),disabled:r||t===null,children:`恢复默认`})]}),(0,_.jsx)(`textarea`,{className:`setp-area`,rows:8,value:t??``,placeholder:`留空 = 用内置默认(附件清单 + 本地路径 + 拉取命令)`,disabled:t===null,onChange:e=>n(e.target.value)}),(0,_.jsxs)(`details`,{className:`setp-tpl-preview`,children:[(0,_.jsx)(`summary`,{children:`可用占位符(完整含义见「变量字典」页)`}),(0,_.jsx)(`pre`,{className:`setp-tpl-preview-body`,children:`{{task.id}} {{task.text}} {{source}} {{summary}} {{cwd}} {{name}}
3
+ {{attach.count}} 附件个数
4
+ {{attach.list}} 附件清单(多行:路径 / 图床 id 与拉取命令)
5
+ {{attach.sync}} 本次同步详情(空串 = 没跑云端同步)
6
+ {{#attachSync}}…{{/attachSync}} 跑过同步才出现的段`})]})]})}function D({listFlag:e,listKey:t,placeholder:n,offText:i}){let o=a(),{dialog:c,node:l}=r(),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(-1),v=(0,g.useCallback)(()=>{s(`/api/localtasks`).then(e=>d(e?.settings?.[t]??[])).catch(e=>o(`读取失败:`+(e.message||e)))},[t,o]);(0,g.useEffect)(()=>{v()},[v]);let y=async n=>{if(!(n==null||f)){p(!0);try{let r=(await s(`/api/localtasks/setting`,{method:`PATCH`,body:{[e]:n}}))?.[t]??[];d(r),o(r.length?`已保存(${r.length} 条)`:i)}catch(e){o(String(e.message||e))}finally{p(!1)}}};return(0,_.jsxs)(`div`,{className:`setp-suffix`,children:[u!==null&&!u.length&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`已关闭`}),u!==null&&(0,_.jsx)(b,{items:u,onChange:d,disabled:f,placeholder:n,sections:!0,accordion:!0,openIndex:m,onOpenChange:h}),(0,_.jsxs)(`div`,{className:`setp-proj-a`,children:[(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:f||u===null||u.length>=x,onClick:()=>{let e=u.length;d([...u,``]),h(e)},children:`添加一条…`}),(0,_.jsx)(`span`,{className:`spacer`}),(0,_.jsx)(`button`,{className:`btn sm`,disabled:f||u===null,onClick:()=>y(u),children:`保存`}),(0,_.jsx)(`button`,{className:`btn ghost sm danger`,disabled:f||u===null,onClick:async()=>{f||u===null||(!u.length||await c({title:`清空并停用?`,message:`将删除全部 ${u.length} 条已配置条目并停用,保存后不可恢复。`,okText:`清空并停用`,danger:!0}))&&y([])},title:`清空全部条目并停用`,children:`停用`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:f,onClick:v,children:`撤销改动`})]}),l]})}function O({openTemplates:e}){let t=a(),n=f(),[r,i]=(0,g.useState)(!1),o=n.templates||[],[s,c]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!o.length){c(null);return}(!s||!o.some(e=>e.id===s))&&c(n.defaultId||o[0].id)},[o,n.defaultId,s]);let l=o.find(e=>e.id===s)||null,u=l?p(l.body,l.values||{}):``,d=async(e,r)=>{i(!0);try{await n.update(e.id,{values:r}),t(`已保存「${e.name}」的槽位内容`)}catch(e){t(String(e.message||e))}finally{i(!1)}};return n.unsupported?(0,_.jsx)(`div`,{className:`setp-note`,children:`当前服务比面板旧——重启面板后才有模板功能。`}):o.length?(0,_.jsxs)(`div`,{className:`setp-tpl-split`,children:[(0,_.jsxs)(`div`,{className:`setp-tpl-side`,children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`选用模板`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>e?.(),children:`管理…`})]}),(0,_.jsx)(`div`,{className:`setp-tpl-list`,role:`listbox`,"aria-label":`任务模板`,children:o.map(e=>(0,_.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.id===s,className:`setp-tpl-pick${e.id===s?` is-on`:``}`,onClick:()=>c(e.id),children:[(0,_.jsx)(`span`,{className:`setp-tpl-name`,children:e.name}),e.id===n.defaultId&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`默认`}),e.builtin&&(0,_.jsx)(`span`,{className:`setp-badge`,children:`内置`})]},e.id))})]}),(0,_.jsx)(`div`,{className:`setp-tpl-main`,children:l?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`setp-row`,children:(0,_.jsxs)(`span`,{children:[`槽位内容 · `,l.name]})}),(0,_.jsx)(h,{body:l.body,values:l.values,disabled:r,onSave:e=>d(l,e)}),u.trim()?(0,_.jsxs)(`details`,{className:`setp-tpl-preview`,children:[(0,_.jsx)(`summary`,{children:`预览新建任务正文`}),(0,_.jsx)(`pre`,{className:`setp-tpl-preview-body`,children:u})]}):null]}):(0,_.jsx)(`div`,{className:`setp-note`,children:`从左侧选一个模板。`})})]}):(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有模板(内置默认模板加载中…)。`})}function k(){let e=a(),[t,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(!1),o=(0,g.useCallback)(()=>{s(`/api/localtasks`).then(e=>n(e?.settings?.deliveryTemplate??``)).catch(t=>e(`读取失败:`+(t.message||t)))},[e]);return(0,g.useEffect)(()=>{o()},[o]),(0,_.jsxs)(`div`,{className:`setp-suffix`,children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`交付上下文模板(原始提示词之外的组 / 项目关键路径)`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:async()=>{if(!r){i(!0);try{let r=await s(`/api/localtasks/setting`,{method:`PATCH`,body:{deliveryTemplate:t??``}});n(r?.deliveryTemplate??``),e(`已保存交付上下文模板`)}catch(t){e(String(t.message||t))}finally{i(!1)}}},disabled:r||t===null,children:`保存`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:async()=>{if(!r){i(!0);try{let t=await s(`/api/localtasks/setting`,{method:`PATCH`,body:{deliveryTemplate:``}});n(t?.deliveryTemplate??``),e(`已恢复内置默认模板`)}catch(t){e(String(t.message||t))}finally{i(!1)}}},disabled:r||t===null,children:`恢复默认`})]}),(0,_.jsx)(`textarea`,{className:`setp-area`,rows:12,value:t??``,placeholder:`留空 = 用内置默认模板`,disabled:t===null,onChange:e=>n(e.target.value)}),(0,_.jsxs)(`details`,{className:`setp-tpl-preview`,children:[(0,_.jsx)(`summary`,{children:`可用占位符`}),(0,_.jsx)(`pre`,{className:`setp-tpl-preview-body`,children:`{{task.text}} 原始提示词(正文逐字)
7
+ {{repo.name}} {{repo.intro}} {{repo.introPath}} {{repo.docs}} 项目介绍与补充文档
8
+ {{group.name}} {{group.desc}} {{group.intro}} {{group.introPath}} {{group.note}} {{group.peers}} {{group.docs}}
9
+ {{source}} {{summary}} {{cwd}} {{name}} {{goal.*}}
10
+ {{params.k}} / {{k}} 外部参数(--param k=v 平铺传入)
11
+ 段落:{{#repo}}…{{/repo}}、{{#group}}…{{/group}}(ctx 里没有就整段不出现)`})]})]})}function A({openTemplates:e}){let[t,n]=(0,g.useState)(`vars`);return(0,_.jsxs)(`div`,{className:`setp-prompts`,children:[(0,_.jsx)(`nav`,{className:`setp-prompts-nav`,"aria-label":`提示词与模板分类`,children:S.map(e=>(0,_.jsx)(`button`,{type:`button`,className:`setp-prompts-tab${t===e.id?` is-on`:``}`,onMouseEnter:()=>n(e.id),onClick:()=>n(e.id),children:e.label},e.id))}),(0,_.jsxs)(`div`,{className:`setp-prompts-pane`,children:[t===`vars`&&(0,_.jsx)(T,{}),t===`template`&&(0,_.jsx)(O,{openTemplates:e}),t===`suffix`&&(0,_.jsx)(D,{listFlag:`suffixList`,listKey:`taskSuffixList`,placeholder:`一条收尾指令(支持 {{task.text}} / {{goal.*}} 占位符)`,offText:`已关闭回调提示词`}),t===`ack`&&(0,_.jsx)(D,{listFlag:`ackList`,listKey:`ackPromptList`,placeholder:`例如:完成总结按「改了什么 · 怎么验证 · 遗留什么」三段写,每段一行`,offText:`已关闭 ack 提示词`}),t===`attach`&&(0,_.jsx)(E,{}),t===`delivery`&&(0,_.jsx)(k,{})]})]})}function j(){let e=a(),t=c()||{},n=t.patchPrefs,[r,i]=(0,g.useState)([]),[o,l]=(0,g.useState)([]),[u,d]=(0,g.useState)([]),f=(0,g.useCallback)(()=>{Promise.all([s(`/api/repos`),s(`/api/boards`)]).then(([e,n])=>{i(Array.isArray(e)?e:e?.repos||[]),l(Array.isArray(n)?n:n?.boards||[]),d(t.prefs?.hidden||[])}).catch(t=>e(`读取失败:`+(t.message||t)))},[e,t.prefs]);(0,g.useEffect)(()=>{f()},[f]);let p=e=>{let r=t.prefs?.hidden||[],i=r.includes(e)?r.filter(t=>t!==e):[...r,e];n&&n({hidden:i}),d(i)},m=(e,t,n,r)=>(0,_.jsx)(`div`,{className:`setp-row`,children:(0,_.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`},children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:!u.includes(t),onChange:()=>p(t)}),(0,_.jsx)(`span`,{children:n}),r?(0,_.jsx)(`span`,{className:`mono faint`,children:r}):null]})},e+`:`+t);return(0,_.jsxs)(`div`,{className:`setp-side`,children:[(0,_.jsx)(`div`,{className:`setp-note`,children:`勾掉的项目组 / 项目不在侧边栏显示(登记与数据都留着,随时勾回来)。`}),(0,_.jsx)(`div`,{className:`setp-row`,children:(0,_.jsx)(`span`,{children:`项目组(指针)`})}),o.map(e=>m(`board`,e.key||e.id,e.name,`${(e.repos||[]).length} 个模块`)),!o.length&&(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有项目组。`}),(0,_.jsx)(`div`,{className:`setp-row`,children:(0,_.jsx)(`span`,{children:`项目 / 仓库(模块)`})}),r.map(e=>m(`repo`,e.key||e.id,e.name,e.path)),!r.length&&(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有登记仓库。`})]})}var M=10,N=`不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get(带 --summary 当前现状)领取下一条任务,直到 get 返回 timeout 为止。`,P=[{id:`pref`,label:`偏好`,icon:`flow`},{id:`work`,label:`工作区`,icon:`sidebar`},{id:`cloud`,label:`云端与存储`,icon:`cloud`},{id:`prompts`,label:`提示词 / 模板`,icon:`list`},{id:`sidebar`,label:`侧栏显示`,icon:`sidebar`},{id:`template`,label:`任务工具`,icon:`clock`},{id:`project`,label:`项目级设置`,icon:`repo`}];function F({repo:e,docStateOf:t,openDoc:n,bindExternal:r,unbind:o}){let l=c()||{},u=a(),[d,f]=(0,g.useState)(e.icon||``),[p,m]=(0,g.useState)(!1),[h,v]=(0,g.useState)(!1);(0,g.useEffect)(()=>{f(e.icon||``)},[e.icon]);let y=async t=>{let n=String(t??d).trim();if(n===String(e.icon||``).trim()){m(!1);return}v(!0);try{await s(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{icon:n}}),f(n),u(n?`已保存「${e.name}」的图标`:`已清除「${e.name}」的图标`),l.refreshRepos&&l.refreshRepos(),m(!1)}catch(e){u(String(e.message||e))}finally{v(!1)}},b=t(e),x=!!(e.getLoop&&e.getLoop.enabled);return(0,_.jsxs)(`div`,{className:`setp-proj`,children:[(0,_.jsxs)(`div`,{className:`setp-proj-head`,children:[(0,_.jsx)(`div`,{className:`setp-icon`+(p?` open`:``),children:(0,_.jsx)(`button`,{type:`button`,className:`setp-icon-btn`,title:d?`项目图标:${d}(点击修改)`:`设置项目图标(emoji / 单字符)`,"aria-label":`项目图标`,"aria-expanded":p,onClick:()=>m(e=>!e),children:d?(0,_.jsx)(`span`,{className:`setp-icon-glyph`,"aria-hidden":!0,children:d}):(0,_.jsx)(i,{name:`folder`,size:14})})}),(0,_.jsxs)(`div`,{className:`setp-proj-meta`,children:[(0,_.jsxs)(`div`,{className:`setp-proj-t`,children:[(0,_.jsx)(`b`,{children:e.name}),(0,_.jsx)(`span`,{className:`setp-badge `+b.kind,children:b.kind===`external`?`外部`:b.kind===`own`?`自有`:`约定`}),x&&(0,_.jsx)(`span`,{className:`setp-badge loop`,children:`持续 get`})]}),(0,_.jsx)(`div`,{className:`setp-proj-p mono`,title:b.label,children:b.label})]}),(0,_.jsxs)(`div`,{className:`setp-proj-actions`,children:[(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>n(e),children:`介绍`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>r(e),children:`绑定…`}),e.doc?(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>o(e),children:`解绑`}):null]})]}),p&&(0,_.jsxs)(`div`,{className:`setp-icon-edit`,role:`group`,"aria-label":`编辑项目图标`,children:[(0,_.jsx)(`input`,{autoFocus:!0,value:d,maxLength:8,placeholder:`emoji 或单字符`,onChange:e=>f(e.target.value),onKeyDown:t=>{t.key===`Enter`&&(t.preventDefault(),y(d)),t.key===`Escape`&&(t.preventDefault(),f(e.icon||``),m(!1))},disabled:h}),(0,_.jsx)(`button`,{type:`button`,className:`btn sm`,disabled:h,onClick:()=>y(d),children:`保存`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:h||!d,title:`清空,侧栏回退默认文件夹图标`,onClick:()=>y(``),children:`清除`}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:h,onClick:()=>{f(e.icon||``),m(!1)},children:`取消`})]}),(0,_.jsx)(L,{repo:e})]})}var I=2e3;function L({repo:e}){let t=c()||{},n=a(),r=e.getLoop&&typeof e.getLoop==`object`?e.getLoop:null,[i,o]=(0,g.useState)(!!(r&&r.enabled)),[l,u]=(0,g.useState)(String(r&&r.waitMinutes||10)),[d,f]=(0,g.useState)(()=>{let e=r&&r.template;return(Array.isArray(e)?e:e==null?[]:[e]).map(e=>String(e??``).trim()).filter(Boolean).map(e=>e.replaceAll(`{{task.id}}`,`%s`))}),[p,m]=(0,g.useState)(-1),[h,v]=(0,g.useState)(``),[y,x]=(0,g.useState)([]),[S,C]=(0,g.useState)(!1);(0,g.useEffect)(()=>{s(`/api/localtasks`).then(e=>x(e?.settings?.taskSuffixList??[])).catch(()=>x([]))},[]);let w=async()=>{C(!0);try{let r=d.map(e=>String(e??``).trim().replaceAll(`%s`,`{{task.id}}`)).filter(Boolean).slice(0,M);await s(`/api/repos/`+encodeURIComponent(e.id),{method:`PATCH`,body:{getLoop:{enabled:i,...i?{waitMinutes:Number(l)||10,template:r}:{}}}}),n(i?`已保存「${e.name}」的持续 get 设置(模板 ${r.length} 条)`:`已关闭「${e.name}」的持续 get`),t.refreshRepos&&t.refreshRepos()}catch(e){n(String(e.message||e))}finally{C(!1)}},T=()=>{let e=h.trim();!e||d.length>=M||(f([...d,e.slice(0,I)]),m(d.length),v(``))},E=e=>v(e);return i?(0,_.jsxs)(`div`,{className:`setp-loop`,children:[(0,_.jsxs)(`label`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`持续 get(waitgoal)`}),(0,_.jsxs)(`button`,{className:`toggle`+(i?` on`:``),onClick:()=>o(!1),children:[(0,_.jsx)(`span`,{className:`dot`}),i?`开`:`关`]})]}),i&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`阻塞窗口(分钟)`}),(0,_.jsx)(`input`,{className:`setp-min`,value:l,onChange:e=>u(e.target.value),inputMode:`numeric`})]}),(0,_.jsxs)(`div`,{className:`setp-oneline`,children:[(0,_.jsxs)(`select`,{className:`setp-oneline-pick`,value:``,title:`选提示词模板填入下方输入框`,onChange:e=>{e.target.value&&E(e.target.value),e.target.value=``},children:[(0,_.jsx)(`option`,{value:``,children:`选模板…`}),(0,_.jsx)(`option`,{value:N,children:`内置默认(继续 get 直到 timeout)`}),y.map((e,t)=>(0,_.jsx)(`option`,{value:e,children:(e.split(`
12
+ `)[0]||``).slice(0,40)||`回调提示词 ${t+1}`},t))]}),(0,_.jsx)(`input`,{className:`setp-oneline-input`,value:h,placeholder:`一句话(%s = 任务编号),选模板后可改`,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T()}}),(0,_.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:S||!h.trim(),onClick:T,children:`添加`})]}),d.length?(0,_.jsx)(b,{items:d,onChange:f,disabled:S,placeholder:`一句话(%s = 任务编号)`,accordion:!0,openIndex:p,onOpenChange:m}):(0,_.jsx)(`div`,{className:`setp-note`,children:`未配置模板 —— 用默认「继续调用 localtask get 直到 timeout」。`}),(0,_.jsxs)(`div`,{className:`setp-proj-a`,children:[(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:S||d.length>=M,title:d.length>=M?`最多 ${M} 条`:`新增一条「继续 get」指令`,onClick:()=>{f([...d,``]),m(d.length)},children:`添加一条…`}),(0,_.jsx)(`button`,{className:`btn sm`,disabled:S,onClick:w,children:`保存持续 get 设置`})]})]})]}):(0,_.jsxs)(`button`,{className:`setp-gl-off`,title:`开启持续 get(waitgoal)`,onClick:()=>o(!0),children:[(0,_.jsx)(`span`,{className:`dot`}),`持续 get`]})}function R(){let e=c()||{},t=a(),{dialog:n,node:l}=r(),u=e.prefs||{},d=e.patchPrefs||(()=>{}),f=e.model,p=e.repoData&&e.repoData.repos||[],[m,h]=(0,g.useState)(`pref`),[v,y]=(0,g.useState)(null),[b,x]=(0,g.useState)(!1),S=(0,g.useCallback)(async()=>{try{y(await s(`/api/setting`))}catch(e){t(`读取设置失败:`+(e.message||e))}},[t]);(0,g.useEffect)(()=>{S()},[S]);let C=e=>e().catch(e=>t(String(e.message||e))),w=e=>C(async()=>{x(!0);try{y(await s(`/api/setting`,{method:`POST`,body:e})),t(`已保存`)}finally{x(!1)}}),T=e=>e.doc&&e.doc.path?{kind:`external`,docId:`path:`+e.doc.path,label:e.doc.path}:e.doc&&e.doc.rel?{kind:`own`,docId:`rel:`+e.doc.rel,label:e.doc.rel}:{kind:`default`,docId:`rel:`+(e.docRel||``),label:e.docRel||`(未创建)`},E=e=>{if(!f)return;let n=T(e);if(!n.docId||n.docId===`rel:`)return t(`这个项目还没有介绍文档`);o(f,{component:`doc`,name:e.name+` · 介绍`,config:{docId:n.docId},location:`center`})},D=r=>C(async()=>{let i=await n({title:`绑定外部介绍文档`,input:!0,placeholder:`D:\\vault\\nx\\nx-kv.md(只读引用,不进导出包)`});i&&(await s(`/api/docs/bind`,{method:`POST`,body:{repo:r.key,path:i.trim()}}),t(`已绑定:${i.trim()}`),e.refreshRepos&&e.refreshRepos())}),O=n=>C(async()=>{await s(`/api/docs/bind`,{method:`POST`,body:{repo:n.key,reset:!0}}),t(`已解除绑定(回到约定路径)`),e.refreshRepos&&e.refreshRepos()}),k={pref:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`侧边栏默认收起`}),(0,_.jsxs)(`button`,{className:`toggle`+(u.defaultFolded?` on`:``),onClick:()=>d({defaultFolded:!u.defaultFolded}),children:[(0,_.jsx)(`span`,{className:`dot`}),u.defaultFolded?`开`:`关`]})]}),(u.hidden||[]).length>0&&(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsxs)(`span`,{children:[`隐藏仓库 `,u.hidden.length,` 个`]}),(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>d({hidden:[]}),children:`恢复显示`})]})]}),work:(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`布局`}),(0,_.jsx)(`button`,{className:`btn ghost sm`,onClick:async()=>{await n({title:`重置为初始两栏`,message:`丢掉存下来的布局,回到初始的两栏(目录 + 开始)?`,okText:`重置`})&&e.shell&&e.shell.resetLayout()},children:`重置为初始两栏`})]})}),cloud:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`读任务时自动下载附件`}),(0,_.jsxs)(`button`,{className:`toggle`+(v&&v.autoSyncAttachments?` on`:``),disabled:!v||b,onClick:()=>w({autoSyncAttachments:!v.autoSyncAttachments}),children:[(0,_.jsx)(`span`,{className:`dot`}),v&&v.autoSyncAttachments?`开`:`关`]})]}),(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`附件目录`}),(0,_.jsxs)(`span`,{className:`setp-input`,children:[(0,_.jsx)(`input`,{value:v&&v.attachmentsDir||``,placeholder:`(默认 ~/.nx-kv/attachments/)`,onChange:e=>y(t=>({...t,attachmentsDir:e.target.value}))}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:!v||b,onClick:()=>w({attachmentsDir:v.attachmentsDir}),children:`保存`})]})]}),(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`参考仓库存储根`}),(0,_.jsxs)(`span`,{className:`setp-input`,children:[(0,_.jsx)(`input`,{value:v&&v.gitRepoRoot||``,placeholder:`(未设置 —— clone 参考仓库前先设)`,onChange:e=>y(t=>({...t,gitRepoRoot:e.target.value}))}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:!v||b,onClick:()=>w({gitRepoRoot:v.gitRepoRoot}),children:`保存`})]})]}),(0,_.jsxs)(`div`,{className:`setp-row`,children:[(0,_.jsx)(`span`,{children:`开发仓库克隆根`}),(0,_.jsxs)(`span`,{className:`setp-input`,children:[(0,_.jsx)(`input`,{value:v&&v.gitDevRoot||``,placeholder:`(未设置 —— 导入布局时只登记不克隆)`,onChange:e=>y(t=>({...t,gitDevRoot:e.target.value}))}),(0,_.jsx)(`button`,{className:`btn ghost sm`,disabled:!v||b,onClick:()=>w({gitDevRoot:v.gitDevRoot}),children:`保存`})]})]})]}),prompts:(0,_.jsx)(A,{openTemplates:()=>{f&&o(f,{component:`templates`,name:`任务模板`,config:{},location:`center`})}}),sidebar:(0,_.jsx)(j,{}),project:(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)(`div`,{className:`setp-projs`,children:[p.map(e=>(0,_.jsx)(F,{repo:e,docStateOf:T,openDoc:E,bindExternal:D,unbind:O},e.key)),!p.length&&(0,_.jsx)(`div`,{className:`setp-note`,children:`还没有登记仓库。`})]})})};return(0,_.jsxs)(`div`,{className:`setp`,children:[(0,_.jsx)(`nav`,{className:`setp-nav`,"aria-label":`设置分区`,children:P.map(e=>(0,_.jsxs)(`button`,{className:`setp-navitem`+(m===e.id?` on`:``),"aria-current":m===e.id,onMouseEnter:()=>h(e.id),onClick:()=>h(e.id),children:[(0,_.jsx)(i,{name:e.icon,size:14}),(0,_.jsx)(`span`,{children:e.label})]},e.id))}),(0,_.jsxs)(`div`,{className:`setp-body`,children:[(0,_.jsx)(`div`,{className:`setp-h`,children:P.find(e=>e.id===m).label}),k[m]]}),l]})}export{R as default};
@@ -1 +1 @@
1
- .setp{height:100%;min-height:0;color:var(--ink);font-size:12.5px;display:flex}.setp-nav{background:var(--soft);border-right:1px solid var(--line);flex-direction:column;flex:none;gap:2px;width:172px;padding:10px 8px;display:flex;overflow:auto}.setp-navitem{cursor:pointer;text-align:left;width:100%;color:var(--ink-2);background:0 0;border:0;border-radius:6px;align-items:center;gap:8px;padding:7px 9px;font-family:inherit;font-size:12.5px;display:flex}.setp-navitem:hover{background:var(--soft-2);color:var(--ink)}.setp-navitem.on{background:var(--paper);color:var(--ink);font-weight:650;box-shadow:0 1px 2px #14161a12}.setp-navitem .ic{color:var(--mid)}.setp-navitem.on .ic{color:var(--ink)}.setp-body{flex-direction:column;flex:1;gap:10px;min-width:0;padding:12px 16px 18px;display:flex;overflow:auto}.setp-h{letter-spacing:1px;color:var(--mid);text-transform:uppercase;font:600 10.5px Bahnschrift,Segoe UI,sans-serif}.setp-row{justify-content:space-between;align-items:center;gap:10px;min-height:26px;display:flex}.setp-row>span:first-child{color:var(--ink-2)}.setp-row .toggle{flex:none}.setp-input{flex:1;align-items:center;gap:6px;min-width:0;display:flex}.setp-input input{border:1px solid var(--line);background:var(--paper);min-width:0;height:24px;color:var(--ink);border-radius:6px;flex:1;padding:0 8px;font:400 11.5px ui-monospace,Consolas,monospace}.setp-input input:focus{outline:2px solid var(--soft-2);outline-offset:-1px}.setp-note{color:var(--faint);font-size:11px;line-height:1.65}.setp-projs{flex-direction:column;gap:8px;display:flex}.setp-proj{border:0;border-bottom:1px solid var(--line);background:var(--paper);grid-template-columns:1fr auto;align-items:center;gap:6px 10px;padding:8px 2px;display:grid}.setp-proj-head{grid-column:1}.setp-proj>.setp-gl-off{grid-column:2;justify-self:end}.setp-proj>.setp-loop{grid-column:1/-1}.setp-gl-off{font:inherit;color:var(--faint);cursor:pointer;background:0 0;border:0;border-radius:999px;flex:none;align-items:center;gap:5px;padding:2px 7px;font-size:10.5px;display:inline-flex}.setp-gl-off:hover{background:var(--soft);color:var(--ink)}.setp-gl-off .dot{background:var(--soft-2);border-radius:50%;width:5px;height:5px}.setp-proj:last-child{border-bottom:0}.setp-proj-head{align-items:center;gap:10px;min-width:0;display:flex}.setp-proj-actions{flex:none;align-items:center;gap:6px;display:flex}.setp-proj-actions .btn{color:var(--mid);background:0 0;border-color:#0000}.setp-proj-actions .btn:hover{background:var(--soft);color:var(--ink)}.setp-proj-meta{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.setp-proj-t{flex-wrap:wrap;align-items:center;gap:6px;min-width:0;display:flex}.setp-proj-t b{font-weight:650}.setp-badge{color:var(--mid);background:var(--soft);border-radius:8px;padding:0 6px;font-size:10px}.setp-badge.external{color:#9e4c00;background:#fbf3e4}.setp-badge.own,.setp-badge.loop{color:var(--mdw-accent,#2f6f5e);background:var(--mdw-accent-soft,#e8f2ee)}.setp-proj-p{color:var(--faint);text-overflow:ellipsis;white-space:nowrap;font-size:10.5px;overflow:hidden}.setp-proj-meta{flex:1;align-items:baseline;gap:10px;min-width:0;display:flex;overflow:hidden}.setp-proj-meta .setp-proj-t{flex:none}.setp-proj-meta .setp-proj-p{flex:auto;min-width:0}.setp-proj-a{border-top:1px solid var(--line,#e4e2dc);flex-wrap:wrap;align-items:center;gap:8px;margin-top:14px;padding-top:12px;display:flex}.setp-proj-a .spacer{flex:auto}.setp-icon{flex:none}.setp-icon-btn{border:1px solid var(--line);background:var(--soft);width:32px;height:32px;color:var(--mid);cursor:pointer;border-radius:8px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.setp-icon-btn:hover{background:var(--soft-2);color:var(--ink);border-color:var(--mid)}.setp-icon.open .setp-icon-btn{border-color:var(--mdw-accent,#2f6f5e);box-shadow:0 0 0 2px var(--mdw-accent-soft,#e8f2ee)}.setp-icon-glyph{text-overflow:clip;white-space:nowrap;max-width:1.4em;font-size:16px;line-height:1;overflow:hidden}.setp-icon-edit{border:1px solid var(--line);background:var(--soft);border-radius:8px;flex-wrap:wrap;align-items:center;gap:6px;padding:6px 8px;display:flex}.setp-icon-edit input{border:1px solid var(--line);background:var(--paper);width:88px;height:24px;color:var(--ink);border-radius:6px;padding:0 8px;font:400 12px ui-monospace,Consolas,monospace}.setp-icon-edit input:focus{outline:2px solid var(--soft-2);outline-offset:-1px}.setp-suffix{flex-direction:column;gap:8px;margin-top:4px;display:flex}.setp-suffix-item{align-items:flex-start;gap:6px;display:flex}.setp-suffix-item .setp-suffix-no{color:var(--faint);text-align:right;flex:none;min-width:16px;margin-top:8px;font-family:ui-monospace,Consolas,monospace;font-size:10.5px}.setp-suffix-item .setp-suffix-ta{min-height:64px}.setp-suffix-item .btn{flex:none;margin-top:6px}.setp-suffix-ta{resize:vertical;border:1px solid var(--line);background:var(--paper);width:100%;min-height:110px;color:var(--ink);border-radius:8px;padding:8px 10px;font:400 11.5px/1.7 ui-monospace,Consolas,monospace}.setp-suffix-ta:focus{outline:2px solid var(--soft-2);outline-offset:-1px}.setp-suffix .mono{background:var(--soft);border-radius:4px;padding:0 4px;font-family:ui-monospace,Consolas,monospace;font-size:10.5px}.setp-loop{border-top:1px dashed var(--line);flex-direction:column;gap:6px;margin-top:2px;padding-top:8px;display:flex}.setp-min{border:1px solid var(--line);background:var(--paper);width:72px;height:24px;color:var(--ink);text-align:right;border-radius:6px;padding:0 8px;font:400 11.5px ui-monospace,Consolas,monospace}.setp-min:focus{outline:2px solid var(--soft-2);outline-offset:-1px}.setp-prompts{background:0 0;border:0;border-radius:0;flex-direction:column;gap:0;min-height:0;margin-top:2px;display:flex}.setp-prompts-nav{border-bottom:1px solid var(--line,#e4e2dc);background:0 0;flex:none;align-items:center;gap:4px;padding:2px 0 8px;display:flex}.setp-prompts-tab{cursor:pointer;color:var(--ink-2,#4b515a);background:0 0;border:0;border-radius:999px;padding:4px 12px;font:600 12px inherit}.setp-prompts-tab:hover{background:var(--soft,#f1f0ec);color:var(--ink,#16181c)}.setp-prompts-tab.is-on{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e)}.setp-prompts-pane{flex:1;min-width:0;padding:12px 14px 14px;overflow:auto}.setp-prompts-pane>*{max-width:720px}.setp-tpl-split{align-items:stretch;gap:12px;min-height:200px;display:flex}.setp-tpl-side{flex-direction:column;flex:none;gap:6px;width:148px;display:flex}.setp-tpl-main{flex-direction:column;flex:1;gap:8px;min-width:0;display:flex}.setp-tpl-list{flex-direction:column;gap:4px;margin:0;display:flex}.setp-tpl-pick{cursor:pointer;text-align:left;width:100%;font:inherit;background:0 0;border:1px solid #0000;border-radius:7px;align-items:center;gap:6px;padding:6px 8px;display:flex}.setp-tpl-pick:hover{background:var(--soft,#f1f0ec)}.setp-tpl-pick.is-on{background:var(--mdw-accent-soft,#e8f2ee);border-color:var(--mdw-accent-line,#b7d4c8)}.setp-tpl-name{min-width:0;color:var(--ink,#16181c);flex:1;font-size:12px}.setp-tpl-preview{color:var(--ink-2,#4b515a);margin-top:4px;font-size:11.5px}.setp-tpl-preview summary{cursor:pointer;-webkit-user-select:none;user-select:none}.setp-tpl-preview-body{border:1px solid var(--line,#e4e2dc);background:var(--soft,#f1f0ec);white-space:pre-wrap;border-radius:8px;max-height:180px;margin:6px 0 0;padding:8px 10px;font:400 11.5px/1.55 ui-monospace,Consolas,monospace;overflow:auto}.setp-oneline{align-items:center;gap:6px;min-width:0;margin:6px 0;display:flex}.setp-oneline-pick{max-width:220px;font:inherit;border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);color:var(--ink,#16181c);border-radius:6px;flex:none;padding:3px 6px;font-size:11.5px}.setp-oneline-input{min-width:0;font:inherit;border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);color:var(--ink,#16181c);border-radius:6px;flex:1;padding:4px 8px;font-size:12px}.setp-oneline-input:focus{border-color:var(--mdw-accent,#2f6f5e);outline:none}
1
+ .setp{height:100%;min-height:0;color:var(--ink);font-size:12.5px;display:flex}.setp-nav{background:var(--soft);border-right:1px solid var(--line);flex-direction:column;flex:none;gap:2px;width:172px;padding:10px 8px;display:flex;overflow:auto}.setp-navitem{cursor:pointer;text-align:left;width:100%;color:var(--ink-2);background:0 0;border:0;border-radius:6px;align-items:center;gap:8px;padding:7px 9px;font-family:inherit;font-size:12.5px;display:flex}.setp-navitem:hover{background:var(--soft-2);color:var(--ink)}.setp-navitem.on{background:var(--paper);color:var(--ink);font-weight:650;box-shadow:0 1px 2px #14161a12}.setp-navitem .ic{color:var(--mid)}.setp-navitem.on .ic{color:var(--ink)}.setp-body{flex-direction:column;flex:1;gap:10px;min-width:0;padding:12px 16px 18px;display:flex;overflow:auto}.setp-h{letter-spacing:1px;color:var(--mid);text-transform:uppercase;font:600 10.5px Bahnschrift,Segoe UI,sans-serif}.setp-row{justify-content:space-between;align-items:center;gap:10px;min-height:26px;display:flex}.setp-row>span:first-child{color:var(--ink-2)}.setp-row .toggle{flex:none}.setp-input{flex:1;align-items:center;gap:6px;min-width:0;display:flex}.setp-input input{border:1px solid var(--line);background:var(--paper);min-width:0;height:24px;color:var(--ink);border-radius:6px;flex:1;padding:0 8px;font:400 11.5px ui-monospace,Consolas,monospace}.setp-input input:focus{outline:2px solid var(--soft-2);outline-offset:-1px}.setp-note{color:var(--faint);font-size:11px;line-height:1.65}.setp-projs{flex-direction:column;gap:8px;display:flex}.setp-proj{border:0;border-bottom:1px solid var(--line);background:var(--paper);grid-template-columns:1fr auto;align-items:center;gap:6px 10px;padding:8px 2px;display:grid}.setp-proj-head{grid-column:1}.setp-proj>.setp-gl-off{grid-column:2;justify-self:end}.setp-proj>.setp-loop{grid-column:1/-1}.setp-gl-off{font:inherit;color:var(--faint);cursor:pointer;background:0 0;border:0;border-radius:999px;flex:none;align-items:center;gap:5px;padding:2px 7px;font-size:10.5px;display:inline-flex}.setp-gl-off:hover{background:var(--soft);color:var(--ink)}.setp-gl-off .dot{background:var(--soft-2);border-radius:50%;width:5px;height:5px}.setp-proj:last-child{border-bottom:0}.setp-proj-head{align-items:center;gap:10px;min-width:0;display:flex}.setp-proj-actions{flex:none;align-items:center;gap:6px;display:flex}.setp-proj-actions .btn{color:var(--mid);background:0 0;border-color:#0000}.setp-proj-actions .btn:hover{background:var(--soft);color:var(--ink)}.setp-proj-meta{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.setp-proj-t{flex-wrap:wrap;align-items:center;gap:6px;min-width:0;display:flex}.setp-proj-t b{font-weight:650}.setp-badge{color:var(--mid);background:var(--soft);border-radius:8px;padding:0 6px;font-size:10px}.setp-badge.external{color:#9e4c00;background:#fbf3e4}.setp-badge.own,.setp-badge.loop{color:var(--mdw-accent,#2f6f5e);background:var(--mdw-accent-soft,#e8f2ee)}.setp-proj-p{color:var(--faint);text-overflow:ellipsis;white-space:nowrap;font-size:10.5px;overflow:hidden}.setp-proj-meta{flex:1;align-items:baseline;gap:10px;min-width:0;display:flex;overflow:hidden}.setp-proj-meta .setp-proj-t{flex:none}.setp-proj-meta .setp-proj-p{flex:auto;min-width:0}.setp-proj-a{border-top:1px solid var(--line,#e4e2dc);flex-wrap:wrap;align-items:center;gap:8px;margin-top:14px;padding-top:12px;display:flex}.setp-proj-a .spacer{flex:auto}.setp-icon{flex:none}.setp-icon-btn{border:1px solid var(--line);background:var(--soft);width:32px;height:32px;color:var(--mid);cursor:pointer;border-radius:8px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.setp-icon-btn:hover{background:var(--soft-2);color:var(--ink);border-color:var(--mid)}.setp-icon.open .setp-icon-btn{border-color:var(--mdw-accent,#2f6f5e);box-shadow:0 0 0 2px var(--mdw-accent-soft,#e8f2ee)}.setp-icon-glyph{text-overflow:clip;white-space:nowrap;max-width:1.4em;font-size:16px;line-height:1;overflow:hidden}.setp-icon-edit{border:1px solid var(--line);background:var(--soft);border-radius:8px;flex-wrap:wrap;align-items:center;gap:6px;padding:6px 8px;display:flex}.setp-icon-edit input{border:1px solid var(--line);background:var(--paper);width:88px;height:24px;color:var(--ink);border-radius:6px;padding:0 8px;font:400 12px ui-monospace,Consolas,monospace}.setp-icon-edit input:focus{outline:2px solid var(--soft-2);outline-offset:-1px}.setp-suffix{flex-direction:column;gap:8px;margin-top:4px;display:flex}.setp-suffix-item{align-items:flex-start;gap:6px;display:flex}.setp-suffix-item .setp-suffix-no{color:var(--faint);text-align:right;flex:none;min-width:16px;margin-top:8px;font-family:ui-monospace,Consolas,monospace;font-size:10.5px}.setp-suffix-item .setp-suffix-ta{min-height:64px}.setp-suffix-item .btn{flex:none;margin-top:6px}.setp-suffix-ta{resize:vertical;border:1px solid var(--line);background:var(--paper);width:100%;min-height:110px;color:var(--ink);border-radius:8px;padding:8px 10px;font:400 11.5px/1.7 ui-monospace,Consolas,monospace}.setp-suffix-ta:focus{outline:2px solid var(--soft-2);outline-offset:-1px}.setp-suffix .mono{background:var(--soft);border-radius:4px;padding:0 4px;font-family:ui-monospace,Consolas,monospace;font-size:10.5px}.setp-loop{border-top:1px dashed var(--line);flex-direction:column;gap:6px;margin-top:2px;padding-top:8px;display:flex}.setp-min{border:1px solid var(--line);background:var(--paper);width:72px;height:24px;color:var(--ink);text-align:right;border-radius:6px;padding:0 8px;font:400 11.5px ui-monospace,Consolas,monospace}.setp-min:focus{outline:2px solid var(--soft-2);outline-offset:-1px}.setp-prompts{background:0 0;border:0;border-radius:0;flex-direction:column;gap:0;min-height:0;margin-top:2px;display:flex}.setp-prompts-nav{border-bottom:1px solid var(--line,#e4e2dc);background:0 0;flex:none;align-items:center;gap:4px;padding:2px 0 8px;display:flex}.setp-prompts-tab{cursor:pointer;color:var(--ink-2,#4b515a);background:0 0;border:0;border-radius:999px;padding:4px 12px;font:600 12px inherit}.setp-prompts-tab:hover{background:var(--soft,#f1f0ec);color:var(--ink,#16181c)}.setp-prompts-tab.is-on{background:var(--mdw-accent-soft,#e8f2ee);color:var(--mdw-accent,#2f6f5e)}.setp-prompts-pane{flex:1;min-width:0;padding:12px 14px 14px;overflow:auto}.setp-prompts-pane>*{max-width:720px}.setp-tpl-split{align-items:stretch;gap:12px;min-height:200px;display:flex}.setp-tpl-side{flex-direction:column;flex:none;gap:6px;width:148px;display:flex}.setp-tpl-main{flex-direction:column;flex:1;gap:8px;min-width:0;display:flex}.setp-tpl-list{flex-direction:column;gap:4px;margin:0;display:flex}.setp-tpl-pick{cursor:pointer;text-align:left;width:100%;font:inherit;background:0 0;border:1px solid #0000;border-radius:7px;align-items:center;gap:6px;padding:6px 8px;display:flex}.setp-tpl-pick:hover{background:var(--soft,#f1f0ec)}.setp-tpl-pick.is-on{background:var(--mdw-accent-soft,#e8f2ee);border-color:var(--mdw-accent-line,#b7d4c8)}.setp-tpl-name{min-width:0;color:var(--ink,#16181c);flex:1;font-size:12px}.setp-tpl-preview{color:var(--ink-2,#4b515a);margin-top:4px;font-size:11.5px}.setp-tpl-preview summary{cursor:pointer;-webkit-user-select:none;user-select:none}.setp-tpl-preview-body{border:1px solid var(--line,#e4e2dc);background:var(--soft,#f1f0ec);white-space:pre-wrap;border-radius:8px;max-height:180px;margin:6px 0 0;padding:8px 10px;font:400 11.5px/1.55 ui-monospace,Consolas,monospace;overflow:auto}.setp-oneline{align-items:center;gap:6px;min-width:0;margin:6px 0;display:flex}.setp-oneline-pick{max-width:220px;font:inherit;border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);color:var(--ink,#16181c);border-radius:6px;flex:none;padding:3px 6px;font-size:11.5px}.setp-oneline-input{min-width:0;font:inherit;border:1px solid var(--line,#e4e2dc);background:var(--paper,#fff);color:var(--ink,#16181c);border-radius:6px;flex:1;padding:4px 8px;font-size:12px}.setp-oneline-input:focus{border-color:var(--mdw-accent,#2f6f5e);outline:none}.setp-vars{flex-direction:column;gap:6px;min-width:0;display:flex}.setp-vars-wrap{overflow-x:auto}.setp-vars table{border-collapse:collapse;width:100%;min-width:420px;margin:2px 0 10px;font-size:11.5px}.setp-vars th,.setp-vars td{text-align:left;border-bottom:1px solid var(--line,#e4e2dc);vertical-align:top;padding:4px 8px}.setp-vars th{color:var(--mid,#8a8578);white-space:nowrap;font-weight:600}.setp-vars td:first-child{white-space:nowrap}.setp-vars code{background:var(--soft,#f1f0ec);color:var(--ink,#16181c);border-radius:4px;padding:1px 4px;font:400 11px/1.5 ui-monospace,Consolas,monospace}.setp-vars h4{color:var(--ink,#16181c);margin:10px 0 2px;font-size:12px}
@@ -0,0 +1,7 @@
1
+ import{d as e,f as t,h as n,o as r,r as i,s as a,u as o}from"./attach-v8BxRJ7p.js";import{A as s,B as c,C as l,F as u,I as d,J as f,K as p,L as m,M as h,N as g,P as _,R as v,S as y,T as b,U as x,b as ee,g as S,j as C,k as te,p as w,q as T,v as ne,w as re,y as ie,z as ae}from"./index-CFkF2w23.js";import{t as oe}from"./route-crumb-DTo_wUoT.js";import{i as E}from"./upload-CzUtsVcG.js";import{i as se,n as ce,r as le,t as ue}from"./reopen-text-DIFfS71D.js";import{a as de,i as fe,n as pe,o as me,r as he,t as ge}from"./md-history-BLnTGoI5.js";var D=n(t(),1);function _e(e){let t=S(String(e??``));if(!t.length)return[];let n=[],r=null,i=``;return t.forEach((e,t)=>{let a=String(e||``).trim();if(a===`## 上一轮完成总结`){r={round:n.length+1,blockIndex:t,feedbackBlockIndex:-1,ackText:``,feedbackText:``},n.push(r),i=`ack`;return}if(a===`## 验收反馈`){r&&i===`ack`&&(r.feedbackBlockIndex=t,i=`feedback`);return}a&&r&&(i===`ack`?r.ackText+=(r.ackText?`
2
+ `:``)+a:r.feedbackText+=(r.feedbackText?`
3
+ `:``)+a)}),n.filter(e=>e.ackText!==``)}function ve(e){let t=String(e?.ackText||``).split(`
4
+ `).map(e=>e.replace(/^#+\s*/,``).replace(/\*\*/g,``).trim()).find(e=>e!==``);if(!t)return`第 ${e?.round??1} 轮`;let n=t.length>24?`${t.slice(0,24)}…`:t;return`第 ${e.round} 轮 · ${n}`}var O=f(),k=e();function A(){let[e,t]=(0,D.useState)(!1),[n,r]=(0,D.useState)({x:0,y:0}),i=(0,D.useRef)(null),a=(0,D.useRef)(null);return(0,D.useEffect)(()=>{if(!e)return;let n=e=>{i.current?.contains(e.target)||a.current?.contains(e.target)||t(!1)};return document.addEventListener(`mousedown`,n),()=>document.removeEventListener(`mousedown`,n)},[e]),{open:e,setOpen:t,pos:n,setPos:r,ref:i,menuRef:a}}function ye({menu:e,className:t=``,style:n,children:r}){return e.open?(0,O.createPortal)((0,k.jsx)(`div`,{className:`mdw-fmt-menu${t?` ${t}`:``}`,role:`menu`,ref:e.menuRef,style:{position:`fixed`,...e.pos,...n},children:r}),document.body):null}function j(e,t,n=`left`){let r=t.currentTarget.getBoundingClientRect(),i=r.bottom+4;e.setPos(n===`left`?{left:r.left,top:i}:{left:`auto`,right:Math.max(8,window.innerWidth-r.right),top:i}),e.setOpen(e=>!e)}function be({mode:e,onMode:t,showMark:n,submitLabel:r,onNew:i,onSubmit:a,onChain:o,onPreview:s,onImg:c,onAtt:l,onImport:u,onClone:d,onMark:f,onDraft:p,onDelete:m,onOverview:h,onProg:g,onSource:_,onShortcuts:v,goalBadge:y,goalMenu:b}){let x=A();(0,D.useEffect)(()=>{x.setOpen(!1)},[e]);let ee=[o&&{id:`chain`,label:`任务链`,run:o},s&&{id:`preview`,label:`预览提示词`,run:s},c&&{id:`img`,label:`插入图片`,run:c},l&&{id:`att`,label:`添加附件`,run:l},e!==`split`&&{id:`import`,label:`导入`,run:u},d&&{id:`clone`,label:`克隆任务`,run:d},n&&{id:`mark`,label:`评论`,run:f},e!==`split`&&{id:`draft`,label:`存草稿`,run:p},m&&{id:`delete`,label:`删除`,run:m,danger:!0},{id:`overview`,label:`总览`,run:h},{id:`prog`,label:`进程`,run:g},_&&{id:`source`,label:`原文`,run:_},v&&{id:`shortcuts`,label:`快捷键`,run:v}].filter(Boolean);return(0,k.jsxs)(`div`,{className:`mdw-toolbar`,children:[(0,k.jsxs)(`div`,{className:`mdw-toolbar-left`,children:[(0,k.jsx)(me,{mode:e,onChange:t}),y&&(0,k.jsx)(`button`,{type:`button`,className:`mdw-goal-badge`,title:y.title,"aria-haspopup":`menu`,"aria-expanded":x.open,onClick:e=>j(x,e,`right`),children:y.label})]}),(0,k.jsxs)(`div`,{className:`mdw-actions`,role:`group`,"aria-label":`任务操作`,children:[i&&(0,k.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:i,children:`新任务`}),(0,k.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:a,children:r}),(0,k.jsxs)(`div`,{className:`mdw-actions-more`,ref:x.ref,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn ghost sm${x.open?` on`:``}`,title:`更多操作`,"aria-expanded":x.open,"aria-haspopup":`menu`,onClick:e=>j(x,e,`right`),children:`更多`}),(0,k.jsxs)(ye,{menu:x,className:`mdw-act-menu`,children:[b,b&&(0,k.jsx)(`div`,{className:`mdw-fmt-menu-sep`,role:`separator`}),ee.map(e=>(0,k.jsx)(`button`,{type:`button`,role:`menuitem`,className:`mdw-fmt-menu-item`+(e.danger?` danger`:``),onClick:()=>{e.run?.(),x.setOpen(!1)},children:e.label},e.id))]})]})]})]})}var xe=`nx-kv-ack-rail-pos`;function M(e={}){let{x:t,y:n,parentW:r,parentH:i,railW:a=0,railH:o=0,margin:s=8}=e||{};if(![t,n,r,i].every(e=>Number.isFinite(e)))return null;let c=Math.max(s,r-a-s),l=Math.max(s,i-o-s);return{x:Math.min(c,Math.max(s,t)),y:Math.min(l,Math.max(s,n))}}function N(){try{let e=JSON.parse(localStorage.getItem(xe)||`null`);if(!e||typeof e!=`object`)return null;let t=Number(e.x),n=Number(e.y);return!Number.isFinite(t)||!Number.isFinite(n)?null:{x:t,y:n}}catch{return null}}function P(e){try{e?localStorage.setItem(xe,JSON.stringify({x:Math.round(e.x),y:Math.round(e.y)})):localStorage.removeItem(xe)}catch{}}var F=4;function Se(e,t,n){if(!e||t<0)return null;let r=e.querySelector(`.mdw-lp-block[data-i="${t}"]`);if(r)return r;let i=[...e.querySelectorAll(`h2`)].filter(e=>(e.textContent||``).trim()===`上一轮完成总结`);return i[n]?i[n]:null}function Ce({nodes:e=[],scrollRoot:t=null,onJump:n=null}){let[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(0),[s,c]=(0,D.useState)(N),[l,u]=(0,D.useState)(!1),d=(0,D.useRef)(null),f=(0,D.useRef)(null),p=(0,D.useRef)(!1);(0,D.useEffect)(()=>{let e=d.current,t=e&&e.parentElement;if(!e||!t)return;let n=()=>{c(n=>{if(!n)return n;let r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),a=M({x:n.x,y:n.y,parentW:r.width,parentH:r.height,railW:i.width,railH:i.height});return a&&(a.x!==n.x||a.y!==n.y)?a:n})};return n(),window.addEventListener(`resize`,n,{passive:!0}),()=>window.removeEventListener(`resize`,n)},[]);let m=(0,D.useCallback)(e=>{if(e.pointerType===`mouse`&&e.button!==0)return;let t=d.current,n=t&&t.parentElement;if(!t||!n)return;let r=t.style.bottom;t.style.bottom=`auto`;let i=t.getBoundingClientRect();r?t.style.bottom=r:t.style.bottom=``;let a=n.getBoundingClientRect();f.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startLeft:i.left-a.left,startTop:i.top-a.top,parentW:a.width,parentH:a.height,railW:i.width,railH:i.height,moved:!1};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}},[]),h=(0,D.useCallback)(e=>{let t=f.current;if(!t||e.pointerId!==t.pointerId)return;let n=e.clientX-t.startX,r=e.clientY-t.startY;if(!t.moved){if(Math.hypot(n,r)<F)return;t.moved=!0,p.current=!0,u(!0),document.body.style.userSelect=`none`}let i=M({x:t.startLeft+n,y:t.startTop+r,parentW:t.parentW,parentH:t.parentH,railW:t.railW,railH:t.railH});i&&(t.last=i,c(i))},[]),g=(0,D.useCallback)(e=>{let t=f.current;t&&e.pointerId===t.pointerId&&(f.current=null,t.moved&&(u(!1),document.body.style.userSelect=``,P(t.last)))},[]),_=(0,D.useCallback)(()=>{c(null),P(null)},[]),v=(0,D.useMemo)(()=>(e||[]).map(e=>({...e,title:ve(e)})),[e]);(0,D.useEffect)(()=>{let e=t;if(!e||!v.length)return;let n=()=>{let t=e.getBoundingClientRect(),n=0;for(let r of v){let i=Se(e,r.blockIndex,r.round-1);i&&i.getBoundingClientRect().top-t.top<=40&&(n=r.round)}o(n)};return n(),e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[t,v]);let y=(0,D.useCallback)(e=>{let r=t,i=r?Se(r,e.blockIndex,e.round-1):null;i&&(i.scrollIntoView({behavior:`smooth`,block:`start`}),o(e.round)),n?.(e)},[t,n]);return v.length?(0,k.jsxs)(`aside`,{ref:d,className:`doc-rail ack-rail`+(r?` open`:``)+(l?` dragging`:``),style:s?{left:s.x,top:s.y,right:`auto`,bottom:`auto`}:void 0,"aria-label":`验收轮次`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`doc-rail-menu`,title:r?`收起轮次(双击回默认位)`:`展开轮次 · 按住拖动 · 双击回默认位`,"aria-expanded":r,onClick:()=>{if(p.current){p.current=!1;return}i(e=>!e)},onPointerDown:m,onPointerMove:h,onPointerUp:g,onPointerCancel:g,onDoubleClick:_,children:[(0,k.jsx)(`span`,{}),(0,k.jsx)(`span`,{}),(0,k.jsx)(`span`,{})]}),(0,k.jsx)(`div`,{className:`doc-rail-ticks`,role:`navigation`,"aria-label":`验收轮次`,children:v.map(e=>(0,k.jsx)(`button`,{type:`button`,className:`doc-rail-tick`+(a===e.round?` on`:``),style:{"--tw":`18px`},title:e.title,"aria-current":a===e.round?`true`:void 0,onClick:()=>y(e)},e.round))}),r&&(0,k.jsx)(`div`,{className:`doc-rail-panel`,children:(0,k.jsxs)(`div`,{className:`doc-rail-sec`,children:[(0,k.jsx)(`div`,{className:`doc-rail-sec-lab`,children:`验收轮次`}),v.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`doc-rail-row`+(a===e.round?` on`:``),title:e.ackText,onClick:()=>y(e),children:[`第 `,e.round,` 轮`]},e.round))]})})]}):null}function we({attachments:e,onRemove:t}){return e?.length?(0,k.jsxs)(`div`,{className:`mdw-attach`,children:[(0,k.jsx)(`div`,{className:`lab`,children:`附件 / 图片`}),(0,k.jsx)(`div`,{className:`list`,children:e.map(e=>(0,k.jsxs)(`div`,{className:`att`,children:[e.type===`image`&&e.url?(0,k.jsx)(`img`,{src:e.url,alt:``}):(0,k.jsx)(`div`,{className:`ico`,children:(0,k.jsx)(a,{name:`list`,size:14})}),(0,k.jsxs)(`div`,{className:`meta`,children:[(0,k.jsx)(`div`,{className:`n`,children:e.name}),(0,k.jsx)(`div`,{className:`s`,children:e.size})]}),(0,k.jsx)(`button`,{type:`button`,className:`x`,"aria-label":`移除`,onClick:()=>t(e.id),children:`×`})]},e.id))})]}):null}var I=`nx-kv-md-attachments-v1`;function Te(){try{return JSON.parse(localStorage.getItem(I)||`{}`)||{}}catch{return{}}}function Ee(e){try{localStorage.setItem(I,JSON.stringify(e))}catch{}}function L(e,t){let n=Te();n[e]=t,Ee(n)}function R(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function z(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}async function B(e){let t=[],n=[];for(let r of[...e]){let e=`a`+Date.now()+Math.random().toString(16).slice(2,6),i=/^image\//.test(r.type),a={id:e,name:r.name,type:i?`image`:`file`,size:R(r.size)};i&&(a.url=await z(r),n.push(`\n![${r.name}](${r.name})\n`)),t.push(a)}return{items:t,imageInserts:n,fileInserts:[]}}async function De(e,t={}){let n=[...e||[]];if(!n.length)return{items:[],imageInserts:[],fileInserts:[]};try{let e=await E(n,{...t.group?{group:t.group}:{},local:!0}),r=[],i=[],a=[];for(let t of e){let e=t.fileId||t.id,n=!!t.isImage;r.push({id:e,name:t.name,type:n?`image`:`file`,size:R(Number(t.size)||0),url:`/api/file/content/${e}`});let o=t.markdown||{},s=n?o.image||`![${t.name}](${e})`:o.file||`[${t.name}](${e})`;(n?i:a).push(`\n${s}\n`)}return{items:r,imageInserts:i,fileInserts:a}}catch{return B(e)}}var Oe=[{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 ke(e){let t=[],n=e.clipboardData;if(!n)return t;if(n.files?.length)for(let e of n.files)t.push(e);if(!t.length&&n.items?.length){for(let e of n.items)if(e.kind===`file`){let n=e.getAsFile();n&&t.push(n)}}return t}function Ae({at:e,onFormat:t,onComment:n,onCopy:r,onCompose:i,onClose:a}){let[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(``),[u,d]=(0,D.useState)({items:[],inserts:``}),[f,p]=(0,D.useState)(!1),m=(0,D.useRef)(null),h=(0,D.useRef)(null);if((0,D.useEffect)(()=>{s(!!e?.comment),l(``),d({items:[],inserts:``})},[e?.text,e?.x,e?.y,e?.comment,e?.mode]),(0,D.useEffect)(()=>{if(!o)return;let e=requestAnimationFrame(()=>m.current?.focus());return()=>cancelAnimationFrame(e)},[o]),!e)return null;let g=e.kind||`task`,_=g===`format`||g===`both`,v=String(e.text||``),y=v.length>72?`${v.slice(0,72)}…`:v,b=e.mode===`feedback`||e.mode===`redo`,x=b?`反馈:写下要改的地方(将新开任务)`:`划线评论(回写本任务)`,ee=!!c.trim()||u.items.length>0,S=()=>{s(!0),i?.()},C=()=>{s(!1),l(``),d({items:[],inserts:``}),a?.()},te=()=>{ee&&!f&&n?.({text:c.trim(),attachments:u.items,inserts:u.inserts,mode:b?`feedback`:`comment`,quote:v})},w=async e=>{if(e?.length){p(!0);try{let{items:t,imageInserts:n,fileInserts:r}=await De(e),i=[...n||[],...r||[]].join(``);d(e=>({items:[...e.items,...t],inserts:`${e.inserts}${i}`}))}finally{p(!1),h.current&&(h.current.value=``)}}};return(0,k.jsx)(`div`,{id:`mdw-sel-menu`,className:`mdw-sel-menu open kind-${o?`comment`:g}`,style:{left:e.x,top:e.y},role:`menu`,onMouseDown:e=>{e.target.closest?.(`textarea, input, button`)||e.preventDefault()},children:o?(0,k.jsxs)(`div`,{className:`mdw-sel-comment`,onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation();let t=[...e.dataTransfer?.files||[]];t.length&&w(t)},children:[(0,k.jsx)(`div`,{className:`mdw-sel-comment-cap`,children:x}),v?(0,k.jsx)(`div`,{className:`mdw-sel-quote`,title:v,children:y}):null,(0,k.jsx)(`textarea`,{ref:m,className:`mdw-sel-comment-ta`,rows:3,value:c,placeholder:b?`写下反馈…可粘贴/拖入图片`:`对此处提出问题…可粘贴/拖入图片`,"aria-label":b?`反馈文本`:`评论文本`,onChange:e=>l(e.target.value),onPaste:e=>{let t=ke(e);t.length&&(e.preventDefault(),w(t))},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),C();return}e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),te())}}),u.items.length?(0,k.jsx)(`div`,{className:`mdw-sel-att-list`,children:u.items.map(e=>(0,k.jsxs)(`span`,{className:`mdw-sel-att-chip`,title:e.name,children:[e.type===`image`?`🖼`:`📎`,` `,e.name]},e.id))}):null,(0,k.jsxs)(`div`,{className:`mdw-sel-comment-acts`,children:[(0,k.jsx)(`input`,{ref:h,type:`file`,multiple:!0,hidden:!0,accept:`image/*,*/*`,onChange:e=>w(e.target.files)}),(0,k.jsx)(`button`,{type:`button`,className:`ghost`,disabled:f,title:`添加图片或附件(也可粘贴/拖入)`,onClick:()=>h.current?.click(),children:f?`上传中…`:`附件`}),(0,k.jsx)(`span`,{className:`grow`}),(0,k.jsx)(`button`,{type:`button`,className:`ghost`,onClick:C,children:`取消`}),(0,k.jsx)(`button`,{type:`button`,className:`primary`,disabled:!ee||f,onClick:te,children:b?`新开任务`:`回写本任务`})]}),(0,k.jsx)(`div`,{className:`mdw-sel-comment-hint`,children:`Ctrl/⌘+Enter 提交 · 粘贴/拖入图片 · 附件`})]}):(0,k.jsx)(k.Fragment,{children:_?(0,k.jsxs)(`div`,{className:`mdw-sel-fmt`,role:`group`,"aria-label":`选区格式`,children:[Oe.map(e=>(0,k.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn ${e.cls}`,title:e.title,onClick:()=>t?.(e.op),children:e.label},e.op)),(0,k.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,k.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn`,title:`复制`,onClick:r,children:`复制`}),(0,k.jsx)(`span`,{className:`mdw-sel-sep`,"aria-hidden":!0}),(0,k.jsx)(`button`,{type:`button`,className:`mdw-sel-fmt-btn comment`,title:`划线评论 → 回写本任务`,onClick:S,children:`评论`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`cap`,children:`选区`}),(0,k.jsx)(`button`,{type:`button`,onClick:S,children:`评论`}),(0,k.jsx)(`div`,{className:`sep`}),(0,k.jsx)(`button`,{type:`button`,onClick:r,children:`复制选区`})]})})})}var je=[{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 Me({onClose:e}){return(0,k.jsx)(i,{title:`快捷键`,onClose:e,size:`lg`,className:`mdw-sheet`,children:(0,k.jsx)(`div`,{className:`mdw-sheet-cols`,children:je.map(e=>(0,k.jsxs)(`section`,{className:e.title===`导航与文件`?`wide`:void 0,children:[(0,k.jsx)(`h4`,{children:e.title}),(0,k.jsx)(`dl`,{children:e.items.map(([e,t])=>(0,k.jsxs)(`div`,{className:`mdw-sheet-row`,children:[(0,k.jsx)(`dt`,{children:(0,k.jsx)(`kbd`,{children:e})}),(0,k.jsx)(`dd`,{children:t})]},e))})]},e.title))})})}var Ne={origin:`起点`,reopen:`反馈`,comment:`评论`,current:`当前`};function Pe({nodes:e=[],onOpenNode:t}){return e.length?(0,k.jsx)(`ol`,{className:`mdw-chain-list`,"aria-label":`任务链节点`,children:e.map((n,r)=>{let i=n.current?`current`:n.historyId==null?`t-${n.dirKey||``}-${n.taskId??r}`:`h-${n.historyId}`,a=Ne[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,k.jsxs)(`li`,{className:`mdw-chain-li${n.current?` is-current`:``}`,children:[(0,k.jsxs)(`div`,{className:`mdw-chain-rail`,"aria-hidden":!0,children:[(0,k.jsx)(`span`,{className:`mdw-chain-dot`}),r<e.length-1?(0,k.jsx)(`span`,{className:`mdw-chain-line`}):null]}),(0,k.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,k.jsx)(`span`,{className:`mdw-chain-kind`,children:a}),(0,k.jsx)(`span`,{className:`mdw-chain-ex`,children:o||`—`}),s?(0,k.jsx)(`span`,{className:`mdw-chain-meta`,children:s}):null]})]},i)})}):(0,k.jsx)(`div`,{className:`mdw-chain-empty muted`,children:`这条任务还没有链(反馈 / 评论派生后会出现)`})}function Fe({open:e,nodes:t,onOpenNode:n,onClose:r}){return e?(0,k.jsxs)(i,{title:`任务链`,onClose:r,size:`md`,className:`mdw-chain-modal`,children:[(0,k.jsx)(`p`,{className:`mdw-chain-hint`,children:`从早到晚排列。点非当前节点可在旁路打开内容。`}),(0,k.jsx)(Pe,{nodes:t,onOpenNode:e=>{n?.(e),r?.()}})]}):null}function Ie({dirKey:e,task:t,beside:n=!1,tabId:i,model:a,historyId:f=null}){let S=x()||{},E=o(),{dialog:me,node:ve}=r(),O=S.rows||[],A=S.refreshLocal,ye=S.tpl,j=!e||e===`__GLOBAL__`,xe=v(e),M=g(t),N=C(xe,t),P=(0,D.useMemo)(()=>j?O.find(e=>e.isGlobal)||null:O.find(t=>t.key===e)||null,[O,e,j]),F=(0,D.useMemo)(()=>(P?.tasks||[]).find(e=>String(e.id)===String(t))||null,[P,t]),Se=ae(),I=Se[N]||null,[Te,Ee]=(0,D.useState)(null);(0,D.useEffect)(()=>{Ee(null)},[N]);let R=F?.timegoal||null,z=Te||{duration:R?.duration||``,prompt:R?.prompt||``},B=M||!!F&&F.status!==`consumed`,Oe=`nx-kv/review/${xe}/${t}`,[ke,je]=(0,D.useState)(()=>{try{return localStorage.getItem(Oe)===`1`}catch{return!1}});(0,D.useEffect)(()=>{je(()=>{try{return localStorage.getItem(Oe)===`1`}catch{return!1}})},[Oe]);let Ne=()=>{try{localStorage.setItem(Oe,`1`)}catch{}je(!0),E(`已验收`)},Pe=()=>{let e=Je.current,t=e?.closest?.(`.mdw`),n=e?.getBoundingClientRect(),r=t?.getBoundingClientRect(),i=n&&r?n.left-r.left+80:80,a=n&&r?n.top-r.top-190:120;G({kind:`task`,text:``,comment:!0,mode:`feedback`,x:Math.min(window.innerWidth-320,Math.max(8,i)),y:Math.min(window.innerHeight-260,Math.max(8,a))})},Ie=e=>{let t=e&&typeof e==`object`?e:{text:String(e||``),mode:W?.mode===`feedback`||W?.mode===`redo`?`feedback`:`comment`,quote:K.current||``};if(t.mode===`feedback`||t.mode===`redo`||W?.mode===`feedback`||W?.mode===`redo`){ze(t);return}Be(t)},Re=async()=>{if(M||t==null||/^draft/i.test(String(t)))return null;let e=j?`key=${encodeURIComponent(c)}&id=${Number(t)}`:`cwd=${encodeURIComponent(P?.cwd||``)}&id=${Number(t)}`;return p(`/api/localtasks/item?${e}`).catch(()=>null)},ze=({text:n,attachments:r=[],inserts:i=``}={})=>{let a=String(n||``).trim();if($(),!a&&!(r&&r.length)){E(`写一下反馈`);return}let o=I?.title||`#${t}`;X(async()=>{let n=await Re(),s=String(n?.text??``).trim()||String(I?.body??``).trim();if(!s&&!M){E(`拿不到任务当前正文,已取消反馈(防止丢内容)`);return}let c=a||`(见附件)`;i&&(c=`${c}${i}`);let l=ue({base:s,feedback:c,ackSummary:n?.roundSummary||F?.roundSummary||``,feedbackHeading:ce,bold:!0}),u=!M&&t!=null&&!/^draft/i.test(String(t))?{forkOf:String(t),forkKind:`reopen`}:{},d=await p(`/api/localtasks`,{method:`POST`,body:j?{global:!0,text:l,...u}:{cwd:P?.cwd,text:l,...u}}),f=String(d?.task?.id??d?.id??``);if(!f){E(`反馈已提交,但未拿到新任务编号`),A();return}let h=d?.key||e;m(C(v(h),f),{title:y(l),body:l}),r?.length&&L(f,r),E(`已反馈「${o}」→ 新任务 #${f}`),A(),S.openPage&&S.openPage({dirKey:h,task:f,name:`${o.slice(0,24)}(反馈)`})})},Be=({text:n,attachments:r=[],inserts:o=``,quote:s}={})=>{let l=String(n||``).trim(),u=String(s||K.current||``).trim();if($(),!l&&!(r&&r.length)){E(`写一下要提的问题`);return}if(!u&&!l){E(`先划选一段再评论`);return}if(M||t==null||/^draft/i.test(String(t))){E(`草稿先提交成任务再评论`);return}let d=I?.title||`#${t}`;X(async()=>{let n=!Ze&&!o&&!(r&&r.length),s;if(!n){let e=await Re(),t=String(e?.text??``).trim()||String(I?.body??``).trim();if(!t){E(`拿不到任务当前正文,已取消评论(防止丢内容)`);return}let n=[se(u),l||`(见附件)`,o].filter(Boolean).join(`
5
+
6
+ `);s=ue({base:t,feedback:n,ackSummary:``,feedbackHeading:le,bold:!1})}let f=await p(`/api/localtasks/reopen`,{method:`POST`,body:{...j?{key:c}:{cwd:P?.cwd},id:Number(t),...s?{text:s}:{},kind:`comment`,quote:u,feedback:l,attachments:(r||[]).map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,url:e.url||``}))}}),h=f?.key||e,g=String(f?.task?.id??t),_=String(f?.task?.text??s??``);_&&m(C(v(h),g),{title:y(_),body:_}),r?.length&&L(g,[...I?.attachments||[],...r]),a&&i&&h!==e&&a.doAction(T.updateNodeAttributes(i,{config:{dirKey:h,task:g}})),J(!1),E(`已回写评论「${d}」#${g}`),A()})},V=(0,D.useMemo)(()=>I?l(I.body):{},[I&&I.body]),H=(0,D.useMemo)(()=>{if(n)return null;let r=String(V.parent||``).trim(),i=String(V.parentDir||e||``).trim();if(r&&!/^draft/i.test(r))return{dirKey:i||e,task:r,name:`#${r}`};let a=String(I?.body||``).match(/>\s*锚定自「([^」]+)」/);if(!a)return null;let o=a[1].trim(),s=(P?.tasks||[]).find(e=>String(e.id)===String(t)?!1:y(e.text||``)===o||String(e.text||``).includes(`# ${o}`));return s?{dirKey:e,task:String(s.id),name:`#${s.id}`}:null},[n,V.parent,V.parentDir,I?.body,e,P,t]),U=(0,D.useMemo)(()=>{let e=V.board;if(!e)return null;let t=(S.repoData&&S.repoData.boards||[]).find(t=>t.id===e||t.key===e||t.name===e);if(!t)return null;let n=S.repoData&&S.repoData.repos||[],r=new Map(n.map(e=>[e.key,e]));return{board:t,members:(t.repos||[]).map(e=>r.get(e.key)).filter(Boolean).map(e=>({key:e.key,name:e.name}))}},[V.board,S.repoData]);(0,D.useEffect)(()=>{Se[N]||(M?h(N,{title:``,body:ye?ye.defaultBody():``}):F&&h(N,{title:y(F.text),body:F.text}))},[N,M,F]);let[W,G]=(0,D.useState)(null),[Ve,He]=(0,D.useState)(!1),[Ue,We]=(0,D.useState)(!1),Ge=(0,D.useRef)(null),Ke=(0,D.useRef)(null),qe=(0,D.useRef)(null),Je=(0,D.useRef)(null),Ye=(0,D.useRef)(null),Xe=(0,D.useRef)(null),K=(0,D.useRef)(``),q=(0,D.useRef)(new Map),[Ze,J]=(0,D.useState)(!1),[Y,Qe]=(0,D.useState)(!1),[$e,et]=(0,D.useState)(!1),tt=String(F?.roundSummary||``).length>140;(0,D.useEffect)(()=>{Qe(!1),et(!1)},[N,F?.roundSummary]),(0,D.useLayoutEffect)(()=>{let e=Ye.current;if(!e){et(!1);return}let t=()=>{Y||et(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()}},[Y,F?.roundSummary,F?.completedAt]);let nt=(0,D.useMemo)(()=>I?ne(ee(I.body),I.attachments):``,[I]),rt=(0,D.useMemo)(()=>F?.roundSummary?ne(F.roundSummary):``,[F?.roundSummary]),it=(0,D.useMemo)(()=>I?_e(I.body):[],[I&&I.body]),[at,ot]=(0,D.useState)(null);(0,D.useEffect)(()=>{let e=qe.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()},[I&&I.mode]),(0,D.useEffect)(()=>{G(null),K.current=``},[N]),(0,D.useEffect)(()=>{let e=()=>G(e=>e?.comment?e:null);return document.addEventListener(`scroll`,e,!0),()=>document.removeEventListener(`scroll`,e,!0)},[]);let X=e=>e().catch(e=>E(String(e.message||e))),st=()=>{let n=a||S.model;if(!n)return;let r=V&&V.board?String(V.board):``;s(n,{component:`progress`,name:`进程`,config:r?{groupKey:r,task:t==null?void 0:String(t)}:{dirKey:e||`__GLOBAL__`,task:t==null?void 0:String(t)},location:`right`})},ct=(0,D.useCallback)(()=>{if(!H){E(`这条任务没有可定位的原文`);return}let e=a||S.model;e&&te(e,{component:`page`,name:H.name||`原文 ${H.task}`,config:{dirKey:H.dirKey,task:String(H.task)}})},[H,a,S.model,E]),lt=(0,D.useCallback)(n=>{let r=a||S.model;if(r&&!M){if(n?.current){E(`当前节点就是本页`);return}if(n?.historyId!=null){te(r,{component:`page`,name:`链 #${t} · ${n.kind||n.historyId}`,config:{dirKey:e||`__GLOBAL__`,task:String(t),historyId:Number(n.historyId)}});return}if(n?.taskId!=null&&n?.dirKey){te(r,{component:`page`,name:n.excerpt?String(n.excerpt).slice(0,24):`#${n.taskId}`,config:{dirKey:String(n.dirKey),task:String(n.taskId)}});return}E(`这个节点没有可打开的内容`)}},[a,S.model,M,e,t,E]),ut=(0,D.useCallback)(()=>{let e=a||S.model;e&&i&&e.doAction(T.deleteTab(i))},[a,S.model,i]),[dt,ft]=(0,D.useState)(null);(0,D.useEffect)(()=>{if(M||t==null||/^draft/i.test(String(t))){ft(null);return}let e=!1,n=j?`key=${encodeURIComponent(c)}&id=${Number(t)}`:`cwd=${encodeURIComponent(P?.cwd||``)}&id=${Number(t)}`;return p(`/api/localtasks/chain?${n}`).then(t=>{e||ft(t)}).catch(()=>{e||ft(null)}),()=>{e=!0}},[M,t,j,P?.cwd,F?.history?.length,F?.forkOf,F?.reopenCount]);let pt=(0,D.useMemo)(()=>{if(M||!F)return[];let n=(String(F.text||``).split(`
7
+ `).map(e=>e.trim()).find(Boolean)||``).replace(/^#+\s*/,``).slice(0,100),r=Array.isArray(F.history)?F.history:[];if(r.length){let e=r.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:F.lastReopenedAt||F.createdAt||``,excerpt:n,attachmentCount:0,current:!0}),e}let i=Array.isArray(dt?.ancestors)?[...dt.ancestors].reverse():[],a=Array.isArray(dt?.children)?dt.children:[];if(!i.length&&!a.length&&!F.forkOf)return[];let o=[];for(let e of i)e.missing||o.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});o.push({historyId:null,kind:`current`,at:F.createdAt||``,excerpt:n,attachmentCount:0,current:!0,taskId:Number(t),dirKey:e||`__GLOBAL__`});for(let e of a)o.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 o},[M,F,dt,t,e]),Z=(0,D.useMemo)(()=>{if(f==null||!F)return null;let e=Number(f);return(F.history||[]).find(t=>Number(t.id)===e)||null},[f,F]),Q=(0,D.useCallback)(()=>J(!0),[]),mt=(e,t)=>{let n=(e||``).trim()||`未命名任务`,r=l(t),i=Object.keys(r).length>0,a=re(t);return a=/^#\s+/m.test(a)?a.replace(/^#\s+.+$/m,`# ${n}`):`# ${n}\n\n${a}`,i?b(a,r):a},[ht,gt]=(0,D.useState)(null),_t=(0,D.useCallback)(()=>{gt({busy:!0});let n={cwd:j?P?.cwd||void 0:P?.cwd,key:j?c:e,...M?{text:mt((I?.title||``).trim()||`未命名任务`,I?.body||``)}:{id:Number(t)}};p(`/api/localtasks/preview`,{method:`POST`,body:n}).then(e=>gt({data:e})).catch(e=>gt({error:String(e.message||e)}))},[j,P?.cwd,e,M,I?.title,I?.body,t]),vt=()=>{let e=(z.duration||``).trim(),t=(z.prompt||``).trim();if(t&&!e)return{error:`时间目标要填时长(如 2h / 90m);只写附加要求无效`};if(!B)return{};if(!M){let n=R?.duration||``,r=R?.prompt||``;return e===n&&t===r?{}:e?{duration:e,goalPrompt:t}:{clearGoal:!0}}return e?{duration:e,goalPrompt:t}:{}},yt=()=>X(async()=>{if(!I)return;let n=(I.title||``).trim()||`未命名任务`,r=l(I.body),o=mt(n,I.body),s=r.project?O.find(e=>!e.isGlobal&&e.repo&&e.repo.key===r.project):null,u=!!(U&&r.project&&U.members.some(e=>e.key===r.project)),f=vt();if(f.error){E(f.error);return}if(!M){let r=await p(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:j?s?s.cwd:void 0:P?.cwd,key:j&&!s?c:void 0,id:Number(t),text:o,...f}});if(r?.moved){let s=r.key||e,c=String(r.task?.id??t),l=C(v(s),c);L(c,I.attachments),d(N,l,{title:n,body:r.task?.text||o}),a&&i&&a.doAction(T.updateNodeAttributes(i,{config:{dirKey:s,task:c}})),J(!1),ge(q.current,l),E(`已改归属项目:任务迁到「${r.name}」#${c}`),A();return}L(t,I.attachments),m(N,{title:n,body:o}),J(!1),ge(q.current,N),E(f.clearGoal?`已同步 MD · 时间目标已清除`:f.duration?`已同步 MD · 时间目标已更新`:`已同步 MD`),A();return}let h=await p(`/api/localtasks`,{method:`POST`,body:{...u?{text:o,board:U.board.id,project:r.project}:r.project?{text:o,project:r.project}:j?{global:!0,text:o}:{cwd:P?.cwd,text:o},...f}}),g=h?.task?.id??h?.id;if(g!=null){let t=h?.key||e,r=v(t);L(g,I.attachments);let s=C(r,String(g));d(N,s,{title:n,body:o}),a&&i&&a.doAction(T.updateNodeAttributes(i,{config:{dirKey:t,task:String(g)}})),J(!1),ge(q.current,s)}E(`已提交:${ie(n)}`),A()}),bt=async t=>{let n=await t.text(),r=t.name.replace(/\.md$/i,``);await X(async()=>{let i=n.startsWith(`#`)?n:`# ${r}\n\n${n}`,a=await p(`/api/localtasks`,{method:`POST`,body:j?{global:!0,text:i}:{cwd:P.cwd,text:i}});E(`已导入:${t.name}`),A();let o=a?.task?.id??a?.id;o!=null&&S.openPage&&S.openPage({dirKey:e,task:String(o),name:`#${o}`})})},xt=async()=>{if(!I||M)return;let e=I.title||`#${t}`;await me({title:`删除任务「${e}」`,message:`软删除:CLI localtask task restore 可恢复。`,danger:!0,okText:`删除`})&&X(async()=>{await p(`/api/localtasks/item`,{method:`DELETE`,body:j?{key:c,id:Number(t)}:{cwd:P.cwd,id:Number(t)}}),E(`已删除「${e}」`),a&&i&&a.doAction(T.deleteTab(i)),A()})},St=async(e,n={})=>{if(!I)return;let{items:r,imageInserts:i,fileInserts:a}=await De(e),o=u(N)||I,s=o.body||``,l=i.join(``),d=s,f=null;if(l){let e=w(s,l,n);d=e.body,f=e.insertAt+l.length}a.length&&(d=w(d,a.join(``),{}).body);let h={};if(d!==s&&(h.body=d),r.length&&(h.attachments=[...o.attachments||[],...r]),Object.keys(h).length){if(m(N,h),n.mode===`edit`&&f!=null&&requestAnimationFrame(()=>{Xe.current?.focus?.();let e=document.querySelector(`.mdw-editor`);if(e)try{e.setSelectionRange(f,f)}catch{}}),!M){h.attachments&&L(t,h.attachments);let e=mt(o.title,h.body||d);m(N,{body:e,title:y(e)});try{await p(`/api/localtasks/item`,{method:`PATCH`,body:{cwd:j?void 0:P?.cwd,key:j?c:void 0,id:Number(t),text:e}}),J(!1),A(),E(r.length?`已添加附件并同步(${r.length})`:`已同步附件`)}catch(e){Q(),E(`附件已插入,同步失败:${e.message||e}`)}return}Q()}},$=()=>{G(null),K.current=``},Ct=()=>{let t=_(),n=C(v(e),t),r={};U&&U.board&&U.board.id&&(r.board=U.board.id),V.project&&(r.project=V.project),m(n,{title:``,body:b(ye?ye.defaultBody():``,r)}),S.openPage&&S.openPage({dirKey:e,task:t,name:`新任务`})},wt=()=>{if(M||t==null||/^draft/i.test(String(t))){E(`草稿没有可克隆的队列任务`);return}X(async()=>{let n=await p(`/api/localtasks/clone`,{method:`POST`,body:j?{id:Number(t)}:{id:Number(t),cwd:P?.cwd}});E(`已克隆为新任务 #${n.task?.id??n.id}`),A();let r=n?.task?.id??n?.id;r!=null&&S.openPage&&S.openPage({dirKey:e,task:String(r),name:`${(I?.title||`任务`).slice(0,30)}(克隆)`})})},Tt=()=>{let e=String(window.getSelection()||``).trim()||(W?.text?String(W.text):``);if(!e){E(`先划选一段再评论`);return}K.current=e;let t=(()=>{try{let e=window.getSelection();if(e&&!e.isCollapsed)return e.getRangeAt(0).getBoundingClientRect()}catch{}return null})();G({kind:W?.kind||`task`,text:e,comment:!0,x:Math.min(window.innerWidth-300,Math.max(8,t?t.left+t.width/2-140:W?.x??80)),y:Math.min(window.innerHeight-240,Math.max(8,t?t.bottom+8:W?.y??120))})},Et=(e,t=`typing`)=>{if(!I)return;pe(q.current,N,{title:I.title,body:I.body},t),Q();let n={title:e};I.mode!==`split`&&/^# (?!#)/m.test(I.body)&&(n.body=I.body.replace(/^# (?!#).+$/m,`# ${e||`未命名任务`}`)),m(N,n)},Dt=(e,t=`op`)=>{if(!I)return;pe(q.current,N,{title:I.title,body:I.body},t),Q();let n={body:e};I.mode!==`split`&&(n.title=y(e)),m(N,n)},Ot=()=>{if(!I)return;let e=fe(q.current,N,{title:I.title,body:I.body});e&&(m(N,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>Xe.current?.caretFromDiff?.(I.body,e.body)))},kt=()=>{if(!I)return;let e=he(q.current,N,{title:I.title,body:I.body});e&&(m(N,{title:e.title,body:e.body}),Q(),requestAnimationFrame(()=>Xe.current?.caretFromDiff?.(I.body,e.body)))},At=(e,t,n,r,i={})=>{K.current=t,G({kind:e,text:t,...i,x:Math.min(window.innerWidth-300,Math.max(8,n)),y:Math.min(window.innerHeight-240,Math.max(8,r))})},jt=e=>{if(!e?.text||e.text.length<1){G(e=>e?.comment?e:null);return}G(t=>t?.comment?t:(K.current=e.text,{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))}))},Mt=e=>{if(!I||I.mode===`edit`||e.target.closest?.(`#mdw-sel-menu`)||e.target.closest?.(`textarea`))return;let t=window.getSelection(),n=(t&&String(t)).trim();if(!n||n.length<1){G(e=>e?.comment?e:null);return}if(!qe.current?.contains(t.anchorNode)){G(e=>e?.comment?e:null);return}if(W?.comment)return;let r=t.getRangeAt(0).getBoundingClientRect();At(`task`,n,r.left+r.width/2-140,r.bottom+8)},Nt=e=>{Ke.current.accept=e,Ke.current?.click()};if((0,D.useEffect)(()=>{if(!H||n)return;let e=e=>{(e.ctrlKey||e.metaKey)&&e.shiftKey&&String(e.key||``).toLowerCase()===`o`&&(e.preventDefault(),ct())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[H,n,ct]),f!=null){let e={origin:`起点`,reopen:`反馈`,comment:`评论`}[Z?.kind]||`节点`,t=Z?ne(Z.text||``,Z.attachments||[]):``;return(0,k.jsxs)(`div`,{className:`mdw is-beside`,children:[(0,k.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,k.jsxs)(`span`,{className:`mdw-beside-lab`,children:[`链节点 · `,e,` #`,f]}),(0,k.jsx)(`span`,{className:`grow`}),(0,k.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭`,"aria-label":`关闭`,onClick:ut,children:`×`})]}),(0,k.jsx)(`div`,{className:`mdw-hist-ro`,children:Z?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`mdw-hist-meta`,children:[(0,k.jsx)(`span`,{children:Z.at||`—`}),Z.quote?(0,k.jsxs)(`span`,{children:[`锚定:`,Z.quote.slice(0,80)]}):null,Z.feedback?(0,k.jsxs)(`span`,{children:[`反馈:`,Z.feedback.slice(0,80)]}):null,Z.summary?(0,k.jsxs)(`span`,{children:[`上轮总结:`,Z.summary.slice(0,80)]}):null]}),(0,k.jsx)(`article`,{className:`md-body`,dangerouslySetInnerHTML:{__html:t||`<p class="muted">(空)</p>`}})]}):(0,k.jsxs)(`div`,{className:`muted`,children:[`找不到链节点 #`,f]})})]})}if(!I)return S.localReady===!1||M?(0,k.jsx)(`div`,{className:`mdw`,children:(0,k.jsx)(`div`,{className:`pad muted`,children:`载入中…`})}):(0,k.jsx)(`div`,{className:`mdw`,children:(0,k.jsxs)(`div`,{className:`pad stack`,children:[(0,k.jsx)(`div`,{children:(0,k.jsxs)(`strong`,{children:[`找不到任务 #`,t]})}),(0,k.jsx)(`div`,{className:`hint`,children:`它可能已被删除(软删除可用 nx-kv localtask task restore 恢复),或这个深链写错了。`}),(0,k.jsx)(`div`,{children:(0,k.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>S.onNavigate&&S.onNavigate(j?`#/global`:`#/dir/`+encodeURIComponent(e||``)),children:`回到目录`})})]})});let Pt=(z.duration||``).trim(),Ft=(z.prompt||``).trim(),It=Pt||Ft?{label:`⏱ ${Pt||`目标`}`,title:Ft||(B?`任务级时间目标(在「更多」里设置;领取即计时)`:`已领取计时,声明不可改`)}:null,Lt=B||R?(0,k.jsxs)(`div`,{className:`mdw-goal-menu`,children:[(0,k.jsx)(`div`,{className:`mdw-goal-menu-lab`,children:`时间目标`}),B?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`input`,{className:`mdw-goal-dur mono`,value:z.duration,placeholder:`2h / 90m / 30分钟,留空不带`,onChange:e=>{Ee({...z,duration:e.target.value}),Q()}}),(0,k.jsx)(`input`,{className:`mdw-goal-prompt`,value:z.prompt,placeholder:`附加要求(可选,随 check 指令一起固化)`,onChange:e=>{Ee({...z,prompt:e.target.value}),Q()}})]}):(0,k.jsxs)(`span`,{className:`mdw-goal-ro mono`,title:R?.prompt||`已领取计时,声明不可改`,children:[R?.duration||`—`,` · 已领取计时`]})]}):null;return(0,k.jsxs)(`div`,{className:`mdw${n?` is-beside`:``}`,"data-mode":I.mode||`split`,onMouseUp:Mt,children:[ve,ht&&(0,k.jsx)(Le,{state:ht,onClose:()=>gt(null)}),(0,k.jsx)(Fe,{open:Ue,nodes:pt,onOpenNode:lt,onClose:()=>We(!1)}),n&&(0,k.jsxs)(`div`,{className:`mdw-beside-h`,children:[(0,k.jsx)(`span`,{className:`mdw-beside-lab`,children:`原文(旁路)`}),(0,k.jsx)(`span`,{className:`grow`}),(0,k.jsx)(`button`,{type:`button`,className:`iconbtn`,title:`关闭原文面板`,"aria-label":`关闭原文面板`,onClick:ut,children:`×`})]}),(0,k.jsxs)(`div`,{className:`mdw-main`,children:[(0,k.jsxs)(`div`,{className:`mdw-top`,children:[(0,k.jsx)(oe,{}),(0,k.jsxs)(`div`,{className:`mdw-head`,children:[(0,k.jsx)(`div`,{className:`mdw-title`,children:M?I.title||`新 MD 任务`:I.title||`任务`}),(0,k.jsxs)(`div`,{className:`mdw-path`,children:[j?`全局任务池`:P?.cwd||P?.name||`—`,M?` / (${t})`:` / #${t}`,Ze?` · 未保存`:``]})]})]}),U&&(0,k.jsxs)(`div`,{className:`mdw-goal`,children:[(0,k.jsx)(`span`,{className:`mdw-goal-lab`,title:`归属项目(限本组成员):决定提交进哪个项目的队列;由组面板「新增任务」创建时自动携带本组语义`,children:`归属项目`}),B?(0,k.jsx)(`select`,{className:`mdw-proj-pick`,value:V.project||``,onChange:e=>{m(N,{body:b(I.body,{...V,board:U.board.id,project:e.target.value})}),Q()},children:U.members.map(e=>(0,k.jsx)(`option`,{value:e.key,children:e.name},e.key))}):(0,k.jsx)(`span`,{className:`mdw-proj-ro`,title:`归属项目(在本组创建时写入,随任务走)`,children:(U.members.find(e=>e.key===V.project)||{}).name||V.project||`—`})]}),(0,k.jsx)(be,{mode:I.mode,onMode:e=>m(N,{mode:e}),showMark:I.mode!==`edit`,submitLabel:M?`提交为任务`:`保存并同步`,onNew:Ct,onSubmit:yt,onChain:M?null:()=>We(!0),onPreview:_t,onImg:()=>Nt(`image/*`),onAtt:()=>Nt(`image/*,.pdf,.zip,.txt,.json,.csv`),onImport:()=>Ge.current?.click(),onClone:M?null:wt,onMark:Tt,onDraft:()=>E(`草稿随页签保留(刷新后需从侧栏或页签重新打开)`),onDelete:M?null:xt,onOverview:()=>S.onNavigate&&S.onNavigate(`#/overview`),onProg:st,onSource:H?ct:null,onShortcuts:()=>He(!0),goalBadge:It,goalMenu:Lt}),(0,k.jsx)(de,{ref:qe,mode:I.mode,title:I.title,body:I.body,previewHtml:nt,onTitle:Et,onBody:Dt,attachments:I.attachments,docKey:N,editorApiRef:Xe,onFiles:St,onTextSel:jt,onSave:yt,onUndo:Ot,onRedo:kt,onCloseSelMenu:$}),(0,k.jsx)(we,{attachments:I.attachments,onRemove:e=>{let n=(I.attachments||[]).filter(t=>t.id!==e);Q(),m(N,{attachments:n}),M||L(t,n)}}),!M&&F?.completedAt&&(0,k.jsxs)(`div`,{className:`mdw-review`,ref:Je,children:[(0,k.jsxs)(`div`,{className:`mdw-review-main`,children:[(0,k.jsx)(`span`,{className:`mdw-review-badge`,children:`已完成 · 等待验收`}),(0,k.jsx)(`span`,{className:`mdw-review-at mono`,children:F.completedAt}),F.roundSummary?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{ref:Ye,className:`mdw-review-sum${Y?` is-open`:``}`,title:Y||!($e||tt)?`agent 的完成总结(ack)`:`点击下方展开全文`,dangerouslySetInnerHTML:{__html:rt}}),($e||tt||Y)&&(0,k.jsx)(`button`,{type:`button`,className:`mdw-review-more`,onClick:()=>Qe(e=>!e),children:Y?`收起`:`展开全文`})]}):null]}),(0,k.jsx)(`div`,{className:`mdw-review-acts`,children:ke?(0,k.jsx)(`span`,{className:`mdw-review-ok`,children:`已验收`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`ghost`,onClick:Pe,title:`新开一条任务携带反馈(原任务不动)`,children:`反馈`}),(0,k.jsx)(`button`,{type:`button`,className:`primary`,onClick:Ne,children:`通行`})]})})]})]}),(0,k.jsx)(Ce,{nodes:it,scrollRoot:at}),(0,k.jsx)(Ae,{at:W,onFormat:e=>{Xe.current?.format?.(e),$()},onComment:Ie,onCompose:()=>G(e=>e&&{...e,comment:!0}),onClose:$,onCopy:()=>{navigator.clipboard?.writeText(K.current||W?.text||``),E(`已复制`),$()}}),(0,k.jsx)(`input`,{ref:Ke,type:`file`,multiple:!0,hidden:!0,onChange:e=>{let t=e.target.files;e.target.value=``,t&&t.length&&St(t)}}),(0,k.jsx)(`input`,{ref:Ge,type:`file`,accept:`.md,text/markdown,text/plain`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&bt(t)}}),Ve&&(0,k.jsx)(Me,{onClose:()=>He(!1)})]})}function Le({state:e,onClose:t}){let n=o(),r=e?.data,a=async()=>{try{await navigator.clipboard.writeText(String(r?.rendered||``)),n(`已复制原文`)}catch{n(`复制失败(剪贴板不可用)`)}},s=r?.switches||{},c=r?[`回调提示词 ${s.suffix?.on?`开(${s.suffix.count} 条)`:`关`}`,`ack ${s.ack?.on?`开(${s.ack.count} 条)`:`关`}`,`交付上下文 ${s.deliveryTemplate?.custom?`自定义`:`内置默认`}`,`持续 get ${r.getLoop?.enabled?`开(${r.getLoop.waitMinutes} 分钟)`:`关`}`].join(` · `):``,l=r?`预览:agent 执行 get 会收到的提示词${r.task?.id?` · #${r.task.id}`:` · 草稿`}`:`预览:agent 执行 get 会收到的提示词`;return(0,k.jsxs)(i,{title:l,size:`wide`,onClose:t,footer:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`mdw-prev-hint`,children:`与 CLI 取任务共用同一份排版;不含「已取得下一条任务…」头部行。`}),(0,k.jsx)(`span`,{className:`grow`}),(0,k.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:a,disabled:!r,children:`复制原文`}),(0,k.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:t,children:`关闭`})]}),children:[e.busy&&(0,k.jsx)(`div`,{className:`mdw-prev-note`,children:`渲染中…`}),e.error&&(0,k.jsxs)(`div`,{className:`mdw-prev-note`,children:[`预览失败:`,e.error,/接口不存在/.test(String(e.error))&&(0,k.jsx)(`div`,{className:`mdw-prev-hint`,children:`本机面板服务较旧:重启面板(结束当前 serve 进程后重新启动)即可生效,刷新页面不够。`})]}),r&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`pre`,{className:`mdw-prev-body`,children:r.rendered||``}),r.segments?.length?(0,k.jsxs)(`details`,{className:`mdw-prev-seg`,children:[(0,k.jsxs)(`summary`,{children:[`段落来源(`,r.segments.length,` 段)`]}),(0,k.jsx)(`ol`,{children:r.segments.map((e,t)=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`mdw-prev-seg-lab`,children:e.label}),(0,k.jsxs)(`span`,{className:`mdw-prev-seg-n`,children:[String(e.text||``).length,` 字`]})]},t))}),(0,k.jsx)(`div`,{className:`mdw-prev-note`,children:`改这些段去「设置 → 提示词 / 模板」;「持续 get」在项目级设置里。`})]}):(0,k.jsx)(`div`,{className:`mdw-prev-note`,children:`当前没有任何模板段:交付时就只有任务正文。`}),(0,k.jsx)(`div`,{className:`mdw-prev-switch`,children:c})]})]})}export{Ie as default};
@@ -1 +1 @@
1
- import{d as e,f as t,h as n}from"./attach-v8BxRJ7p.js";import{s as r}from"./index-CbZfbzqr.js";var i=n(t(),1),a=e();function o({body:e,values:t,onSave:n,disabled:o=!1}){let s=(0,i.useMemo)(()=>r(e),[e]),[c,l]=(0,i.useState)(()=>({...t||{}})),[u,d]=(0,i.useState)(!1),f=s.join(`|`)+`::`+JSON.stringify(t||{}),[p,m]=(0,i.useState)(f);if(f!==p&&(m(f),l({...t||{}}),d(!1)),!s.length)return(0,a.jsx)(`div`,{className:`pp-slots-empty`,children:`这个模板正文没有可填槽位——骨架里没有插槽。`});let h=(e,t)=>{l(n=>({...n,[e]:t})),d(!0)};return(0,a.jsxs)(`div`,{className:`pp-slots`,children:[s.map(e=>(0,a.jsxs)(`label`,{className:`pp-slots-row`,children:[(0,a.jsx)(`span`,{className:`pp-slots-name`,title:`骨架插槽「${e}」`,children:e}),(0,a.jsx)(`input`,{className:`pp-slots-input`,value:c[e]??``,disabled:o,placeholder:`这一处写什么(留空 = 空白)`,onChange:t=>h(e,t.target.value)})]},e)),(0,a.jsxs)(`div`,{className:`pp-slots-acts`,children:[(0,a.jsx)(`button`,{type:`button`,className:`btn sm`,disabled:o||!u,onClick:()=>{n?.(c),d(!1)},children:`保存槽位`}),(0,a.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:o||!u,onClick:()=>{l({...t||{}}),d(!1)},children:`撤销改动`})]})]})}export{o as t};
1
+ import{d as e,f as t,h as n}from"./attach-v8BxRJ7p.js";import{s as r}from"./index-CFkF2w23.js";var i=n(t(),1),a=e();function o({body:e,values:t,onSave:n,disabled:o=!1}){let s=(0,i.useMemo)(()=>r(e),[e]),[c,l]=(0,i.useState)(()=>({...t||{}})),[u,d]=(0,i.useState)(!1),f=s.join(`|`)+`::`+JSON.stringify(t||{}),[p,m]=(0,i.useState)(f);if(f!==p&&(m(f),l({...t||{}}),d(!1)),!s.length)return(0,a.jsx)(`div`,{className:`pp-slots-empty`,children:`这个模板正文没有可填槽位——骨架里没有插槽。`});let h=(e,t)=>{l(n=>({...n,[e]:t})),d(!0)};return(0,a.jsxs)(`div`,{className:`pp-slots`,children:[s.map(e=>(0,a.jsxs)(`label`,{className:`pp-slots-row`,children:[(0,a.jsx)(`span`,{className:`pp-slots-name`,title:`骨架插槽「${e}」`,children:e}),(0,a.jsx)(`input`,{className:`pp-slots-input`,value:c[e]??``,disabled:o,placeholder:`这一处写什么(留空 = 空白)`,onChange:t=>h(e,t.target.value)})]},e)),(0,a.jsxs)(`div`,{className:`pp-slots-acts`,children:[(0,a.jsx)(`button`,{type:`button`,className:`btn sm`,disabled:o||!u,onClick:()=>{n?.(c),d(!1)},children:`保存槽位`}),(0,a.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:o||!u,onClick:()=>{l({...t||{}}),d(!1)},children:`撤销改动`})]})]})}export{o as t};
@@ -1,2 +1,2 @@
1
- import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{U as o,v as s}from"./index-CbZfbzqr.js";import{t as c}from"./route-crumb-g3leiQhY.js";import{f as l}from"./md-edit-ops-Bl0Zx0aJ.js";import{t as u}from"./template-slots-D40ponA2.js";var d=n(t(),1),f=e(),p=[{op:`bold`,label:`B`,title:`粗体 Ctrl/⌘B`,cls:`b`},{op:`italic`,label:`I`,title:`斜体 Ctrl/⌘I`,cls:`i`},{op:`code`,label:`</>`,title:`行内代码 Ctrl/⌘E`,cls:`code`},{op:`link`,label:`链`,title:`链接 Ctrl/⌘K`,cls:`link`},{op:`ul`,label:`列表`,title:`无序列表`,cls:`ul`},{op:`todo`,label:`待办`,title:`待办勾选`,cls:`todo`},{op:`quote`,label:`引用`,title:`引用`,cls:`quote`},{op:`h2`,label:`H2`,title:`二级标题`,cls:`h2`},{op:`h3`,label:`H3`,title:`三级标题`,cls:`h3`}],m={b:`bold`,i:`italic`,e:`code`,k:`link`},h=[{id:`split`,label:`并排`},{id:`edit`,label:`源码`},{id:`preview`,label:`预览`}];function g({value:e,onChange:t,onSubmit:n,placeholder:r=`模板正文(Markdown)`,rows:i=10}){let a=(0,d.useRef)(null),[o,c]=(0,d.useState)(`split`),u=(0,d.useMemo)(()=>s(e),[e]),g=e=>{let n=l(a.current,e);n&&(t(n.value),requestAnimationFrame(()=>{let e=a.current;if(e){e.focus();try{e.setSelectionRange(n.start,n.end)}catch{}}}))};return(0,f.jsxs)(`div`,{className:`mdw-tpl-ed`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-ed-bar`,children:[p.map(e=>(0,f.jsx)(`button`,{type:`button`,className:`mdw-fmt-btn ${e.cls}`,title:e.title,onMouseDown:e=>e.preventDefault(),onClick:()=>g(e.op),children:e.label},e.op)),(0,f.jsx)(`span`,{className:`grow`}),(0,f.jsx)(`div`,{className:`mdw-tpl-ed-modes`,role:`group`,"aria-label":`编辑视图`,children:h.map(e=>(0,f.jsx)(`button`,{type:`button`,className:`mdw-tpl-ed-mode`+(o===e.id?` on`:``),"aria-pressed":o===e.id,onClick:()=>c(e.id),children:e.label},e.id))})]}),(0,f.jsxs)(`div`,{className:`mdw-tpl-ed-panes mode-${o}`,children:[o!==`preview`&&(0,f.jsx)(`textarea`,{ref:a,className:`mdw-tpl-ed-src`,value:e,rows:i,spellCheck:!1,placeholder:r,onChange:e=>t(e.target.value),onKeyDown:e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return;let t=e.key.toLowerCase();if(t===`enter`){e.preventDefault(),n?.();return}let r=m[t];r&&(e.preventDefault(),g(r))}}),o!==`edit`&&(0,f.jsx)(`div`,{className:`mdw-tpl-ed-prev`,dangerouslySetInnerHTML:{__html:u}})]})]})}function _(){let e=(o()||{}).tpl,t=a(),{dialog:n,node:s}=r(),[l,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(``),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(null),[C,w]=(0,d.useState)({name:``,body:``}),T=(0,d.useRef)(null);if(!e)return(0,f.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,f.jsx)(c,{}),(0,f.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});let E=(e,n)=>async()=>{if(!_){v(!0);try{await e(),t(n)}catch(e){t(String(e.message||e))}finally{v(!1)}}},D=E(async()=>{if(!(l||``).trim()){t(`先给模板起个名字`),T.current?.focus();return}await e.add(l.trim(),m,!1),p(``),h(``),T.current?.focus()},`已新增模板`),O=e=>{S(e.id),w({name:e.name,body:e.body})},k=()=>S(null),A=E(async()=>{if(!(C.name||``).trim()){t(`模板名不能为空`);return}await e.update(x,{name:C.name.trim(),body:C.body}),S(null)},`已保存模板`),j=t=>E(()=>e.setDefault(t.id),`默认模板已设为「${t.name}」`)(),M=(t,n)=>E(()=>e.update(t.id,{values:n}),`已保存「${t.name}」的槽位内容`)(),N=async t=>{await n({title:`删除模板「${t.name}」`,danger:!0,okText:`删除`})&&E(()=>e.remove(t.id),`已删除「${t.name}」`)()},P=e.templates||[],F=P.find(t=>t.id===e.defaultId)?.name||`内置骨架`,I=e.templates==null,L=e.unsupported?`本机面板服务较旧,没有模板接口 —— 重启面板(nx-kv serve)后重试`:`模板列表加载失败 —— 服务暂时无响应,可点「重试」再试一次`;return(0,f.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[s,(0,f.jsxs)(`div`,{className:`mdw-tpl-panel-inner`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-panel-head`,children:[(0,f.jsx)(`span`,{className:`mdw-tpl-panel-title`,children:`任务模板`}),(0,f.jsx)(`span`,{className:`mdw-tpl-panel-sub`+(I?` bad`:``),children:I?L:`新建页默认使用「${F}」`}),(0,f.jsx)(`span`,{className:`grow`}),!I&&(0,f.jsxs)(`span`,{className:`mdw-tpl-panel-count`,children:[P.length,` 个模板`]})]}),(0,f.jsx)(`div`,{className:`mdw-tpl-panel-note`,children:`模板 = 新建任务页的起始正文。这里的改动即时生效:目录面板的「模板 ▾」与「+ 新建页」用的就是这份列表。`}),(0,f.jsxs)(`div`,{className:`mdw-tpl-list`,children:[P.map(t=>x===t.id?(0,f.jsxs)(`div`,{className:`mdw-tpl-row editing`,children:[(0,f.jsx)(`input`,{className:`mdw-tpl-name-in`,value:C.name,autoFocus:!0,placeholder:`模板名`,onChange:e=>w(t=>({...t,name:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&A()}}),(0,f.jsx)(g,{value:C.body,onChange:e=>w(t=>({...t,body:e})),onSubmit:A,rows:12}),(0,f.jsxs)(`div`,{className:`mdw-tpl-acts end`,children:[(0,f.jsx)(`span`,{className:`mdw-tpl-hint`,children:`Ctrl/⌘ + Enter 保存`}),(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,onClick:k,children:`取消`}),(0,f.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:_,onClick:A,children:`保存`})]})]},t.id):(0,f.jsxs)(`div`,{className:`mdw-tpl-row`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-main`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-name`,children:[t.name,t.id===e.defaultId&&(0,f.jsx)(`span`,{className:`mdw-tpl-def`,children:`默认`}),t.builtin&&(0,f.jsx)(`span`,{className:`mdw-tpl-builtin`,children:`内置`})]}),(0,f.jsx)(`div`,{className:`mdw-tpl-prev`,children:String(t.body||``).trim()||`(空)`})]}),(0,f.jsxs)(`div`,{className:`mdw-tpl-acts`,children:[(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,title:`填槽位(正文里 {{名字}} 处的内容)`,onClick:()=>b(y===t.id?null:t.id),children:y===t.id?`收起槽位`:`填槽位`}),t.id!==e.defaultId&&(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,onClick:()=>j(t),children:`设为默认`}),!t.builtin&&(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,onClick:()=>O(t),children:`编辑`}),!t.builtin&&(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm danger`,disabled:_,title:`删除此模板`,onClick:()=>N(t),children:(0,f.jsx)(i,{name:`trash`,size:12})})]}),y===t.id&&(0,f.jsxs)(`div`,{className:`mdw-tpl-slots`,children:[(0,f.jsx)(u,{body:t.body,values:t.values,disabled:_,onSave:e=>M(t,e)}),(0,f.jsx)(`div`,{className:`mdw-tpl-note`,children:`槽位从正文里扫出来;新建任务时正文按这里的值渲染(内置模板只改槽位,骨架不可改)。`})]})]},t.id)),I&&(0,f.jsx)(`div`,{className:`mdw-tpl-empty`,children:(0,f.jsx)(`div`,{className:`mdw-tpl-retry`,children:(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>e.refetch(),children:`重试`})})}),!I&&!P.length&&(0,f.jsx)(`div`,{className:`mdw-tpl-empty`,children:`还没有自定义模板;下面加一个,或直接用内置的。`})]}),!I&&(0,f.jsxs)(`div`,{className:`mdw-tpl-add`,children:[(0,f.jsx)(`div`,{className:`mdw-tpl-add-h`,children:`新增模板`}),(0,f.jsx)(`input`,{ref:T,className:`mdw-tpl-name-in`,value:l,placeholder:`模板名,如 缺陷修复 / 周报`,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&D()}}),(0,f.jsx)(g,{value:m,onChange:h,onSubmit:D,rows:12,placeholder:`模板正文(Markdown)。
1
+ import{d as e,f as t,h as n,o as r,s as i,u as a}from"./attach-v8BxRJ7p.js";import{U as o,v as s}from"./index-CFkF2w23.js";import{t as c}from"./route-crumb-DTo_wUoT.js";import{d as l}from"./md-edit-ops-BIXUZ5BM.js";import{t as u}from"./template-slots-Bc70bnzR.js";var d=n(t(),1),f=e(),p=[{op:`bold`,label:`B`,title:`粗体 Ctrl/⌘B`,cls:`b`},{op:`italic`,label:`I`,title:`斜体 Ctrl/⌘I`,cls:`i`},{op:`code`,label:`</>`,title:`行内代码 Ctrl/⌘E`,cls:`code`},{op:`link`,label:`链`,title:`链接 Ctrl/⌘K`,cls:`link`},{op:`ul`,label:`列表`,title:`无序列表`,cls:`ul`},{op:`todo`,label:`待办`,title:`待办勾选`,cls:`todo`},{op:`quote`,label:`引用`,title:`引用`,cls:`quote`},{op:`h2`,label:`H2`,title:`二级标题`,cls:`h2`},{op:`h3`,label:`H3`,title:`三级标题`,cls:`h3`}],m={b:`bold`,i:`italic`,e:`code`,k:`link`},h=[{id:`split`,label:`并排`},{id:`edit`,label:`源码`},{id:`preview`,label:`预览`}];function g({value:e,onChange:t,onSubmit:n,placeholder:r=`模板正文(Markdown)`,rows:i=10}){let a=(0,d.useRef)(null),[o,c]=(0,d.useState)(`split`),u=(0,d.useMemo)(()=>s(e),[e]),g=e=>{let n=l(a.current,e);n&&(t(n.value),requestAnimationFrame(()=>{let e=a.current;if(e){e.focus();try{e.setSelectionRange(n.start,n.end)}catch{}}}))};return(0,f.jsxs)(`div`,{className:`mdw-tpl-ed`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-ed-bar`,children:[p.map(e=>(0,f.jsx)(`button`,{type:`button`,className:`mdw-fmt-btn ${e.cls}`,title:e.title,onMouseDown:e=>e.preventDefault(),onClick:()=>g(e.op),children:e.label},e.op)),(0,f.jsx)(`span`,{className:`grow`}),(0,f.jsx)(`div`,{className:`mdw-tpl-ed-modes`,role:`group`,"aria-label":`编辑视图`,children:h.map(e=>(0,f.jsx)(`button`,{type:`button`,className:`mdw-tpl-ed-mode`+(o===e.id?` on`:``),"aria-pressed":o===e.id,onClick:()=>c(e.id),children:e.label},e.id))})]}),(0,f.jsxs)(`div`,{className:`mdw-tpl-ed-panes mode-${o}`,children:[o!==`preview`&&(0,f.jsx)(`textarea`,{ref:a,className:`mdw-tpl-ed-src`,value:e,rows:i,spellCheck:!1,placeholder:r,onChange:e=>t(e.target.value),onKeyDown:e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return;let t=e.key.toLowerCase();if(t===`enter`){e.preventDefault(),n?.();return}let r=m[t];r&&(e.preventDefault(),g(r))}}),o!==`edit`&&(0,f.jsx)(`div`,{className:`mdw-tpl-ed-prev`,dangerouslySetInnerHTML:{__html:u}})]})]})}function _(){let e=(o()||{}).tpl,t=a(),{dialog:n,node:s}=r(),[l,p]=(0,d.useState)(``),[m,h]=(0,d.useState)(``),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(null),[C,w]=(0,d.useState)({name:``,body:``}),T=(0,d.useRef)(null);if(!e)return(0,f.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[(0,f.jsx)(c,{}),(0,f.jsx)(`div`,{className:`pad muted`,children:`模板服务未就绪 —— 面板还在装载。`})]});let E=(e,n)=>async()=>{if(!_){v(!0);try{await e(),t(n)}catch(e){t(String(e.message||e))}finally{v(!1)}}},D=E(async()=>{if(!(l||``).trim()){t(`先给模板起个名字`),T.current?.focus();return}await e.add(l.trim(),m,!1),p(``),h(``),T.current?.focus()},`已新增模板`),O=e=>{S(e.id),w({name:e.name,body:e.body})},k=()=>S(null),A=E(async()=>{if(!(C.name||``).trim()){t(`模板名不能为空`);return}await e.update(x,{name:C.name.trim(),body:C.body}),S(null)},`已保存模板`),j=t=>E(()=>e.setDefault(t.id),`默认模板已设为「${t.name}」`)(),M=(t,n)=>E(()=>e.update(t.id,{values:n}),`已保存「${t.name}」的槽位内容`)(),N=async t=>{await n({title:`删除模板「${t.name}」`,danger:!0,okText:`删除`})&&E(()=>e.remove(t.id),`已删除「${t.name}」`)()},P=e.templates||[],F=P.find(t=>t.id===e.defaultId)?.name||`内置骨架`,I=e.templates==null,L=e.unsupported?`本机面板服务较旧,没有模板接口 —— 重启面板(nx-kv serve)后重试`:`模板列表加载失败 —— 服务暂时无响应,可点「重试」再试一次`;return(0,f.jsxs)(`div`,{className:`mdw-tpl-panel`,children:[s,(0,f.jsxs)(`div`,{className:`mdw-tpl-panel-inner`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-panel-head`,children:[(0,f.jsx)(`span`,{className:`mdw-tpl-panel-title`,children:`任务模板`}),(0,f.jsx)(`span`,{className:`mdw-tpl-panel-sub`+(I?` bad`:``),children:I?L:`新建页默认使用「${F}」`}),(0,f.jsx)(`span`,{className:`grow`}),!I&&(0,f.jsxs)(`span`,{className:`mdw-tpl-panel-count`,children:[P.length,` 个模板`]})]}),(0,f.jsx)(`div`,{className:`mdw-tpl-panel-note`,children:`模板 = 新建任务页的起始正文。这里的改动即时生效:目录面板的「模板 ▾」与「+ 新建页」用的就是这份列表。`}),(0,f.jsxs)(`div`,{className:`mdw-tpl-list`,children:[P.map(t=>x===t.id?(0,f.jsxs)(`div`,{className:`mdw-tpl-row editing`,children:[(0,f.jsx)(`input`,{className:`mdw-tpl-name-in`,value:C.name,autoFocus:!0,placeholder:`模板名`,onChange:e=>w(t=>({...t,name:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&A()}}),(0,f.jsx)(g,{value:C.body,onChange:e=>w(t=>({...t,body:e})),onSubmit:A,rows:12}),(0,f.jsxs)(`div`,{className:`mdw-tpl-acts end`,children:[(0,f.jsx)(`span`,{className:`mdw-tpl-hint`,children:`Ctrl/⌘ + Enter 保存`}),(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,onClick:k,children:`取消`}),(0,f.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:_,onClick:A,children:`保存`})]})]},t.id):(0,f.jsxs)(`div`,{className:`mdw-tpl-row`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-main`,children:[(0,f.jsxs)(`div`,{className:`mdw-tpl-name`,children:[t.name,t.id===e.defaultId&&(0,f.jsx)(`span`,{className:`mdw-tpl-def`,children:`默认`}),t.builtin&&(0,f.jsx)(`span`,{className:`mdw-tpl-builtin`,children:`内置`})]}),(0,f.jsx)(`div`,{className:`mdw-tpl-prev`,children:String(t.body||``).trim()||`(空)`})]}),(0,f.jsxs)(`div`,{className:`mdw-tpl-acts`,children:[(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,title:`填槽位(正文里 {{名字}} 处的内容)`,onClick:()=>b(y===t.id?null:t.id),children:y===t.id?`收起槽位`:`填槽位`}),t.id!==e.defaultId&&(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,onClick:()=>j(t),children:`设为默认`}),!t.builtin&&(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,disabled:_,onClick:()=>O(t),children:`编辑`}),!t.builtin&&(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm danger`,disabled:_,title:`删除此模板`,onClick:()=>N(t),children:(0,f.jsx)(i,{name:`trash`,size:12})})]}),y===t.id&&(0,f.jsxs)(`div`,{className:`mdw-tpl-slots`,children:[(0,f.jsx)(u,{body:t.body,values:t.values,disabled:_,onSave:e=>M(t,e)}),(0,f.jsx)(`div`,{className:`mdw-tpl-note`,children:`槽位从正文里扫出来;新建任务时正文按这里的值渲染(内置模板只改槽位,骨架不可改)。`})]})]},t.id)),I&&(0,f.jsx)(`div`,{className:`mdw-tpl-empty`,children:(0,f.jsx)(`div`,{className:`mdw-tpl-retry`,children:(0,f.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>e.refetch(),children:`重试`})})}),!I&&!P.length&&(0,f.jsx)(`div`,{className:`mdw-tpl-empty`,children:`还没有自定义模板;下面加一个,或直接用内置的。`})]}),!I&&(0,f.jsxs)(`div`,{className:`mdw-tpl-add`,children:[(0,f.jsx)(`div`,{className:`mdw-tpl-add-h`,children:`新增模板`}),(0,f.jsx)(`input`,{ref:T,className:`mdw-tpl-name-in`,value:l,placeholder:`模板名,如 缺陷修复 / 周报`,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&D()}}),(0,f.jsx)(g,{value:m,onChange:h,onSubmit:D,rows:12,placeholder:`模板正文(Markdown)。
2
2
  留空则用内置骨架(## 背景 / ## 验收 / ## 约束 / ## 附件)。`}),(0,f.jsxs)(`div`,{className:`mdw-tpl-add-acts`,children:[(0,f.jsx)(`span`,{className:`mdw-tpl-hint`,children:"首行写 `# 标题`,提交时它就是任务标题;Ctrl/⌘ + Enter 快速添加。"}),(0,f.jsx)(`button`,{type:`button`,className:`btn sm primary`,disabled:_,onClick:D,children:`添加`})]})]})]})]})}export{_ as default};
@@ -1 +1 @@
1
- import{K as e}from"./index-CbZfbzqr.js";var t={"image/png":`.png`,"image/jpeg":`.jpg`,"image/gif":`.gif`,"image/webp":`.webp`,"image/bmp":`.bmp`,"image/svg+xml":`.svg`,"application/pdf":`.pdf`,"text/plain":`.txt`,"text/markdown":`.md`,"text/csv":`.csv`,"application/zip":`.zip`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`.docx`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`.xlsx`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`.pptx`},n=e=>String(e).padStart(2,`0`),r=()=>{let e=new Date;return`${e.getFullYear()}${n(e.getMonth()+1)}${n(e.getDate())}-${n(e.getHours())}${n(e.getMinutes())}${n(e.getSeconds())}`};function i(e){let t=e.clipboardData;if(!t)return[];let n=[];if(t.items)for(let e of t.items){if(e.kind!==`file`)continue;let t=e.getAsFile();t&&n.push(t)}return!n.length&&t.files&&n.push(...Array.from(t.files)),n}function a(e){let t=e.dataTransfer;return t?Array.from(t.files||[]).filter(e=>e&&e.size>0):[]}function o(e,n=0){let i=String(e.name||``).trim();if(!(!i||/^image\.(png|jpe?g)$/i.test(i)||/^blob$/i.test(i)))return i;let a=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)):``,o=t[e.type]||a||`.bin`;return`粘贴图片-${r()}${n>0?`-${n+1}`:``}${o}`}function s(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`读取文件失败: ${e.name||`(无名)`}`)),r.onload=()=>t(String(r.result||``)),r.readAsDataURL(e)})}async function c(t,{group:n,index:r=0,local:i=!1}={}){let a=o(t,r),c=await s(t);return{...await e(`/api/file`,{method:`POST`,body:{name:a,content:c,contentType:t.type||``,group:n,local:i}}),name:a}}async function l(e,{group:t,onProgress:n,local:r=!1}={}){let i=[];for(let a=0;a<e.length;a++)n&&n(a+1,e.length,e[a]),i.push(await c(e[a],{group:t,index:a,local:r}));return i}function u(e){return e.map(e=>e.isImage?e.markdown.image:e.markdown.file).join(` `)}export{l as i,a as n,u as r,i as t};
1
+ import{K as e}from"./index-CFkF2w23.js";var t={"image/png":`.png`,"image/jpeg":`.jpg`,"image/gif":`.gif`,"image/webp":`.webp`,"image/bmp":`.bmp`,"image/svg+xml":`.svg`,"application/pdf":`.pdf`,"text/plain":`.txt`,"text/markdown":`.md`,"text/csv":`.csv`,"application/zip":`.zip`,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":`.docx`,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":`.xlsx`,"application/vnd.openxmlformats-officedocument.presentationml.presentation":`.pptx`},n=e=>String(e).padStart(2,`0`),r=()=>{let e=new Date;return`${e.getFullYear()}${n(e.getMonth()+1)}${n(e.getDate())}-${n(e.getHours())}${n(e.getMinutes())}${n(e.getSeconds())}`};function i(e){let t=e.clipboardData;if(!t)return[];let n=[];if(t.items)for(let e of t.items){if(e.kind!==`file`)continue;let t=e.getAsFile();t&&n.push(t)}return!n.length&&t.files&&n.push(...Array.from(t.files)),n}function a(e){let t=e.dataTransfer;return t?Array.from(t.files||[]).filter(e=>e&&e.size>0):[]}function o(e,n=0){let i=String(e.name||``).trim();if(!(!i||/^image\.(png|jpe?g)$/i.test(i)||/^blob$/i.test(i)))return i;let a=i.includes(`.`)?i.slice(i.lastIndexOf(`.`)):``,o=t[e.type]||a||`.bin`;return`粘贴图片-${r()}${n>0?`-${n+1}`:``}${o}`}function s(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`读取文件失败: ${e.name||`(无名)`}`)),r.onload=()=>t(String(r.result||``)),r.readAsDataURL(e)})}async function c(t,{group:n,index:r=0,local:i=!1}={}){let a=o(t,r),c=await s(t);return{...await e(`/api/file`,{method:`POST`,body:{name:a,content:c,contentType:t.type||``,group:n,local:i}}),name:a}}async function l(e,{group:t,onProgress:n,local:r=!1}={}){let i=[];for(let a=0;a<e.length;a++)n&&n(a+1,e.length,e[a]),i.push(await c(e[a],{group:t,index:a,local:r}));return i}function u(e){return e.map(e=>e.isImage?e.markdown.image:e.markdown.file).join(` `)}export{l as i,a as n,u as r,i as t};
@@ -12,10 +12,10 @@
12
12
  <!-- .ico 兜底:浏览器不认上面的 <link> 时会自己请求 /favicon.ico -->
13
13
  <link rel="icon" type="image/x-icon" href="/favicon.ico">
14
14
  <link rel="apple-touch-icon" sizes="512x512" href="/logo-rounded.png">
15
- <script type="module" crossorigin src="/assets/index-CbZfbzqr.js"></script>
15
+ <script type="module" crossorigin src="/assets/index-CFkF2w23.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="/assets/attach-v8BxRJ7p.js">
17
17
  <link rel="stylesheet" crossorigin href="/assets/attach-BZrdOH46.css">
18
- <link rel="stylesheet" crossorigin href="/assets/index-DUvCgdUV.css">
18
+ <link rel="stylesheet" crossorigin href="/assets/index-DUxHMjZA.css">
19
19
  </head>
20
20
  <body>
21
21
  <div id="root"></div>