lantern-harness 0.1.6 → 0.1.8

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 (91) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +1 -1
  3. package/builtin/session/update-check.mjs +517 -0
  4. package/cli/lantern.mjs +123 -22
  5. package/cli/server.mjs +5 -2
  6. package/dist/500.html +3 -3
  7. package/dist/_astro/Base.DjIEQkT7.css +1 -0
  8. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.D0snmAJ_.js +1 -0
  9. package/dist/_astro/{CaseExecBoard.FJ1Y9b4e.js → CaseExecBoard.BAV4EE3o.js} +1 -1
  10. package/dist/_astro/{CaseGenerateApp.CT2n4VOf.js → CaseGenerateApp.Bz4ryNJG.js} +1 -1
  11. package/dist/_astro/{CasesLibrary.BjrehOiI.js → CasesLibrary.BPifyHUA.js} +1 -1
  12. package/dist/_astro/{ChatApp.Dqfx4FcI.js → ChatApp.DLo31SYZ.js} +5 -5
  13. package/dist/_astro/{DashboardBoard.wILBO_CD.js → DashboardBoard.Bd3eUPwZ.js} +2 -2
  14. package/dist/_astro/{DocsFileBrowser.D32MgVAR.js → DocsFileBrowser.D3cKurQE.js} +1 -1
  15. package/dist/_astro/{DocsPager.BARD7JvD.js → DocsPager.rzu4mnzw.js} +1 -1
  16. package/dist/_astro/{KnowledgeLibrary.C-Sg2R6B.js → KnowledgeLibrary.B0sO4QR1.js} +1 -1
  17. package/dist/_astro/{NavLibraries.BzInZVDf.js → NavLibraries.Cvg3wery.js} +1 -1
  18. package/dist/_astro/{PluginsPage.CVyua_fb.js → PluginsPage.DIltPILi.js} +2 -2
  19. package/dist/_astro/PluginsPage.uvmSuXzi.js +1 -0
  20. package/dist/_astro/PmBugsBoard.CiaIhCHv.js +1 -0
  21. package/dist/_astro/PmIterationsBoard.H67QwKFw.js +1 -0
  22. package/dist/_astro/{PmProjectDetail.CtQdpGes.js → PmProjectDetail.DqDoIg8a.js} +1 -1
  23. package/dist/_astro/PmProjectsBoard.nOC1Hugt.js +1 -0
  24. package/dist/_astro/PmRequirementsBoard.BPjZ7khP.js +1 -0
  25. package/dist/_astro/PmRequirementsBoard.CanxvcKg.js +1 -0
  26. package/dist/_astro/PmShared.CZnXaUq-.js +1 -0
  27. package/dist/_astro/{PromptsLibrary.Z1DQBrFL.js → PromptsLibrary.DU9EuSim.js} +1 -1
  28. package/dist/_astro/{ReportsPage.CGpIPPr9.js → ReportsPage.Cr88iz8c.js} +1 -1
  29. package/dist/_astro/{RequirementsLibrary.D8078xLd.js → RequirementsLibrary.BwriF8F0.js} +1 -1
  30. package/dist/_astro/{SearchableSelect.BTJoZC_a.js → SearchableSelect.Ctg8V1Z1.js} +1 -1
  31. package/dist/_astro/SettingsDialog.DEgsVfaL.js +1 -0
  32. package/dist/_astro/SpaceSwitcher.BEJo5KFi.js +7 -0
  33. package/dist/_astro/{TasksBoard.CL-sNPZN.js → TasksBoard.BZi_GBPG.js} +1 -1
  34. package/dist/_astro/{TemplatesLibrary.d6uIe7I-.js → TemplatesLibrary.T4K9jUex.js} +1 -1
  35. package/dist/_astro/{TestStatsBoard.CSdXWc4Q.js → TestStatsBoard.Dd1Kcmx6.js} +1 -1
  36. package/dist/_astro/{TodosBoard.nl23X5Gi.js → TodosBoard.C4yd_JFb.js} +1 -1
  37. package/dist/_astro/app-config.DKMxjv3g.js +1 -0
  38. package/dist/_astro/i18n.BXeGGutk.js +7 -0
  39. package/dist/_astro/{open-docs-in-session.B5cUxqHi.js → open-docs-in-session.B0ZdZNj2.js} +1 -1
  40. package/dist/_astro/{plugins.DaDJq-mn.js → plugins.D5ypJIXn.js} +1 -1
  41. package/dist/_astro/pm.BsnTv63L.js +4 -0
  42. package/dist/_astro/{settings.CMK4PEak.js → settings.CnDCvwnQ.js} +2 -2
  43. package/dist/_astro/{spaces-client.CoQfaOIO.js → spaces-client.Cai2tHEI.js} +1 -1
  44. package/dist/_astro/update.DXCPfU4a.js +1 -0
  45. package/dist/_astro/{view-prefs.Dhdh8Z5a.js → view-prefs.HCowOWXL.js} +1 -1
  46. package/dist/case-exec/index.html +4 -4
  47. package/dist/cases/generate/index.html +4 -4
  48. package/dist/cases/library/index.html +4 -4
  49. package/dist/dashboard/index.html +4 -4
  50. package/dist/docs/changelog/index.html +25 -4
  51. package/dist/docs/install/index.html +3 -3
  52. package/dist/docs/manual/index.html +15 -5
  53. package/dist/index.html +4 -4
  54. package/dist/knowledge/index.html +4 -4
  55. package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +3 -3
  56. package/dist/plugins/index.html +4 -4
  57. package/dist/pm/bugs/index.html +4 -4
  58. package/dist/pm/iterations/index.html +4 -4
  59. package/dist/pm/projects/detail/index.html +4 -4
  60. package/dist/pm/projects/index.html +4 -4
  61. package/dist/pm/requirements/index.html +4 -4
  62. package/dist/prompts/index.html +4 -4
  63. package/dist/reports/index.html +4 -4
  64. package/dist/requirements/index.html +4 -4
  65. package/dist/tasks/index.html +4 -4
  66. package/dist/templates/index.html +4 -4
  67. package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
  68. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
  69. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +3 -3
  70. package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
  71. package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +3 -3
  72. package/dist/test-stats/index.html +4 -4
  73. package/dist/todos/index.html +4 -4
  74. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +13 -2
  75. package/lh-plugins/lh-pm.mjs +18 -4
  76. package/lh-plugins/lh-update.mjs +171 -0
  77. package/package.json +1 -1
  78. package/dist/_astro/Base.DGaLtzMo.css +0 -1
  79. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.uhTNjhRY.js +0 -1
  80. package/dist/_astro/PluginsPage.CS1GaJtR.js +0 -1
  81. package/dist/_astro/PmBugsBoard.BXUu0kNL.js +0 -1
  82. package/dist/_astro/PmIterationsBoard.Deso1uyK.js +0 -1
  83. package/dist/_astro/PmProjectsBoard.MM4vxneK.js +0 -1
  84. package/dist/_astro/PmRequirementsBoard.62ONLCH5.js +0 -1
  85. package/dist/_astro/PmRequirementsBoard.SLVDgspp.js +0 -1
  86. package/dist/_astro/PmShared.CwCmF-kI.js +0 -1
  87. package/dist/_astro/SettingsDialog.BA57gp90.js +0 -1
  88. package/dist/_astro/SpaceSwitcher.DZ8b_85M.js +0 -7
  89. package/dist/_astro/app-config.huKxSIlN.js +0 -1
  90. package/dist/_astro/i18n.Bbh04ngD.js +0 -7
  91. package/dist/_astro/pm.CpFmMslU.js +0 -4
@@ -0,0 +1,7 @@
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{E as n,f as r,i}from"./app-config.DKMxjv3g.js";import{s as a}from"./plugins.D5ypJIXn.js";import{i as o,n as s,r as c,t as l}from"./dialog.DXHznyjD.js";import{i as ee,n as u,r as d,t as f}from"./menu.Bkluqxic.js";import{t as p}from"./jsx-runtime.BUXbF_vF.js";import{t as m}from"./ConfirmDialog.CBVsDJ8f.js";import{n as h}from"./llm.BZEzE0x2.js";import{f as te}from"./project-docs.Cd2gKPKh.js";import{t as g}from"./prompts-meta.F4wwkjUA.js";import{l as _}from"./settings.CnDCvwnQ.js";import{n as v}from"./i18n.BXeGGutk.js";import{a as y,c as ne,d as re,f as b,i as ie,l as ae,m as oe,n as se,o as x,p as ce,r as le,s as ue,t as de,u as fe}from"./spaces-client.Cai2tHEI.js";var S=e(t(),1),pe=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
2
+ 这份提示词将作为 Lantern Harness 该空间里 AI 助手的默认人设与回答原则。
3
+ 要求:
4
+ - 用「你是…」起头设定角色;
5
+ - 紧扣用户描述的领域与工作方式;
6
+ - 写几条简洁的回答原则(问什么答什么、先结论);
7
+ - 只输出提示词正文,不要解释、不要标题。`;function me(e){let t=String(e??``).replace(/^\uFEFF/,``).trim(),n=/^```(?:markdown|md|text)?\s*\n([\s\S]*?)\n```$/i.exec(t);return n&&(t=n[1].trim()),t}var C=p();function he(e){return e instanceof DOMException&&e.name===`AbortError`||e instanceof Error&&e.name===`AbortError`}function ge({hint:e,children:t}){return e?(0,C.jsx)(`span`,{className:`inline-flex cursor-help`,"data-hint":e,"data-hint-always":``,children:t}):t}function _e(e){let{value:t,onChange:n,onGenerate:r,onStop:i,generating:a,disabled:o}=e,s=(0,S.useRef)(null);(0,S.useLayoutEffect)(()=>{let e=s.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,96)}px`)},[t]);let c=!!t.trim()&&!a&&!o;return(0,C.jsxs)(`div`,{className:`tw-space-prompt-composer pt-1 rounded-lg bg-white border border-stone-200 outline-none transition-colors focus-within:ring-2 focus-within:ring-[#4176e6]/30 focus-within:border-[#4176e6]`,children:[(0,C.jsx)(`textarea`,{ref:s,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){if(e.preventDefault(),a){i();return}c&&r()}},placeholder:v(`space.promptBriefPlaceholder`),rows:1,disabled:o,className:`block w-full min-h-6 pl-3.5 pr-2 pt-0.5 pb-0 text-sm leading-5 text-stone-800 bg-transparent resize-none focus:outline-none placeholder:text-stone-400 disabled:opacity-60`}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-2 px-3 pb-2 pt-1`,children:[(0,C.jsx)(`span`,{className:`flex-1`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>a?i():r(),disabled:!a&&!c,"aria-label":v(a?`space.promptStop`:`space.promptGenerate`),className:`w-7 h-7 shrink-0 rounded-full flex items-center justify-center outline-none transition-colors ${a?`bg-stone-200 text-stone-700 hover:bg-stone-300`:`bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:bg-[#a9c3ef] disabled:cursor-not-allowed`}`,children:a?(0,C.jsx)(`span`,{className:`w-2.5 h-2.5 bg-current rounded-xs`}):(0,C.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`w-4 h-4`,"aria-hidden":!0,children:[(0,C.jsx)(`path`,{d:`m5 12 7-7 7 7`}),(0,C.jsx)(`path`,{d:`M12 19V5`})]})})]})]})}function ve(e){return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2 mb-1.5`,children:[(0,C.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:v(`space.promptBodyLabel`)}),(0,C.jsx)(`span`,{className:`text-[11px] text-stone-400 font-mono truncate`,children:g})]}),(0,C.jsx)(`textarea`,{value:e.value,onChange:t=>e.onChange(t.target.value),placeholder:v(`space.promptBodyPlaceholder`),rows:8,disabled:e.disabled,className:`w-full min-h-36 px-3 py-2 text-sm leading-relaxed rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors resize-y font-[inherit]`}),(0,C.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-snug`,children:e.hint??v(`space.promptHint`)})]})}function w({open:e,onClose:t,onListChanged:n}){let[a,ee]=(0,S.useState)(null),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(``),[b,w]=(0,S.useState)(``),[T,E]=(0,S.useState)(!1),[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(``),[j,ye]=(0,S.useState)(``),[M,N]=(0,S.useState)(null),[P,F]=(0,S.useState)(``),[I,L]=(0,S.useState)(``),[be,R]=(0,S.useState)(``),[z,xe]=(0,S.useState)(!1),[Se,Ce]=(0,S.useState)(!1),[B,V]=(0,S.useState)(null),[H,U]=(0,S.useState)(null),[W,we]=(0,S.useState)(``),[G,K]=(0,S.useState)([]),[Te,q]=(0,S.useState)({}),Ee=(0,S.useRef)(null),De=(0,S.useRef)(null),Oe=(0,S.useRef)(null),J=(0,S.useRef)(null),[ke,Ae]=(0,S.useState)(null),Y=(0,S.useCallback)(async(e=!1)=>{e&&d(`stats`);let t=await re({stats:e});e&&d(null),t?(ee(t),n?.(t)):p(`无法读取数据空间列表(本地服务未运行?)`)},[n]),je=(0,S.useRef)(Y);(0,S.useEffect)(()=>{je.current=Y},[Y]);function X(){J.current?.abort()}(0,S.useEffect)(()=>{e?(p(``),w(``),E(!1),N(null),je.current(!1)):(X(),E(!1),N(null),Ae(null))},[e]);async function Me(e){if(ke||u!==null)return;let t=(e===`create`?k:I).trim();if(!t){p(v(`space.promptNeedReq`));return}p(``);let n=new AbortController;J.current=n,Ae(e);try{await i();let r=_();if(!r?.apiKey?.trim()||!r.model?.trim()||!r.baseURL?.trim()){p(v(`space.promptNeedModel`));return}let a=(e===`create`?D:P).trim(),o=await h(r,[{role:`system`,content:pe},{role:`user`,content:(a?`空间名称:${a}\n\n`:``)+`用户要求:\n${t}`}],n.signal);if(n.signal.aborted)return;let s=me(o);if(!s){p(v(`space.promptGenEmpty`));return}e===`create`?ye(s):R(s)}catch(e){if(he(e)||n.signal.aborted)return;p(e instanceof Error?e.message:String(e))}finally{J.current===n&&(J.current=null),Ae(null)}}function Ne(){X(),p(``),w(``),O(``),A(``),ye(``),E(!0),requestAnimationFrame(()=>De.current?.scrollIntoView({block:`nearest`}))}async function Pe(){if(u!==null)return;let e=D.trim();if(!e){p(v(`space.needName`));return}X();let t=j.trim(),n=k.trim();d(`create`),p(``);let i=await se(e,{switch:!0,...t?{systemPrompt:t}:{},...n?{promptBrief:n}:{}});if(d(null),!i.ok){p(i.error||v(`space.create`)+` 失败`);return}let a=i.space?.id;a&&r(a),window.location.reload()}async function Fe(e){X(),p(``),w(``),N(e),F(e.name),L(``),Ce(!1),R(``),xe(!0),requestAnimationFrame(()=>Oe.current?.scrollIntoView({block:`nearest`}));let t=await ne(e.id),n=``,r=``;if(t.ok)n=t.brief??``,r=t.systemPrompt??``;else if(e.isActive)try{r=(await te(`prompts`,g)).content.trim()}catch{}if(xe(!1),!t.ok&&!r){N(null),p(t.error||v(`space.detailFailed`));return}t.space&&F(t.space.name),R(r);let i=!n.trim()&&!!r;L(i?r:n),Ce(i)}async function Ie(){if(!M||u!==null)return;let e=P.trim();if(!e){p(v(`space.needName`));return}X(),d(`update`),p(``);let t=await oe(M.id,{name:e,...Se?{}:{brief:I},systemPrompt:be});if(d(null),!t.ok){p(t.error||v(`space.updateFailed`));return}let n=!!(t.space&&t.space.name!==M.name),r=M.isActive;N(null),w(v(`space.updated`,{name:t.space?.name??e})),n&&r?window.location.reload():await Y(!1)}async function Le(e){if(e.isActive||u!==null)return;d(`update`),p(``);let t=await ce(e.id);d(null),t.ok?window.location.reload():p(t.error||`切换失败`)}async function Re(){if(!H)return;let e=W.trim();if(!e)return;d(`copy`),p(``);let t=await de(H.id,e);d(null),t.ok?(U(null),w(`已复制为「${t.space?.name}」`),await Y(!1)):p(t.error||`复制失败`)}async function ze(e,t){d(`delete`),p(``);let n=await le(e.id,t);d(null),n.ok?(V(null),e.isActive?(r(`public`),window.location.reload()):(w(n.warning?n.warning:n.purged?`已删除「${e.name}」及其数据`:`已从列表移除「${e.name}」(数据保留在磁盘)`),await Y(!1))):p(n.error||`删除失败`)}async function Be(){d(`discover`),p(``),w(``),K([]);let e=await ie();if(d(null),!e.ok){p(e.error||`扫描失败`);return}let t=e.added?.length??0,n=e.backfilled?.length??0,r=e.skipped?.length??0,i=e.candidates??[],a=[];t?a.push(v(`space.discoverAdded`,{n:t})):i.length||a.push(v(`space.discoverNone`)),n&&a.push(v(`space.discoverBackfilled`,{n})),r&&a.push(v(`space.discoverSkipped`,{n:r})),w(a.join(`;`)),K(i),q(Object.fromEntries(i.map(e=>[e.path,e.hasContent===!0]))),await Y(!1)}async function Ve(){let e=G.filter(e=>Te[e.path]).map(e=>e.path);if(!e.length){K([]),w(v(`space.candidatesIgnored`));return}d(`discover`),p(``);let t=await ie(e);if(d(null),!t.ok){p(t.error||`纳入失败`);return}K([]);let n=t.added?.length??0,r=t.skipped??[],i=[n?v(`space.candidatesAdopted`,{n}):v(`space.candidatesIgnored`)];r.length&&i.push(v(`space.candidatesRejected`,{names:r.map(e=>e.reason).join(`、`)})),w(i.join(`;`)),await Y(!1)}async function He(e){let t=e.target.files?.[0];if(e.target.value=``,!t)return;d(`import`),p(``);let n=await fe(t);d(null),n.ok?(w(`已导入为「${n.space?.name}」`),await Y(!1)):p(n.error||`导入失败`)}let Z=a?.spaces??[],Ue=new Map(Z.map((e,t)=>[e.id,t])),We=e=>e.isPublic?0:e.isActive?1:2,Ge=[...Z].sort((e,t)=>We(e)-We(t)||(Ue.get(e.id)??0)-(Ue.get(t.id)??0)),Q=a?.baseRoot,$=u!==null,Ke=ke===`create`,qe=ke===`edit`;return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(c,{open:e,onClose:t,transition:!0,className:`relative z-95`,children:[(0,C.jsx)(l,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,C.jsxs)(o,{transition:!0,className:`tw-dialog-panel-anim tw-space-dialog w-full max-w-4xl rounded-xl shadow-xl border border-stone-200 bg-white flex flex-col h-[86vh]`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-5 pt-4 pb-3 border-b border-stone-200`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(s,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:v(`space.manageTitle`)}),(0,C.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 leading-relaxed`,children:v(`space.manageDesc`)})]}),(0,C.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:(0,C.jsx)(`button`,{type:`button`,onClick:t,className:`tw-confirm-cancel w-7 h-7 flex items-center justify-center rounded-md text-stone-400 hover:bg-stone-100 hover:text-stone-700 transition-colors`,"aria-label":`关闭`,children:`✕`})})]}),(0,C.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4`,children:[f?(0,C.jsxs)(`div`,{className:`mb-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 flex items-start gap-2`,children:[(0,C.jsx)(`span`,{className:`flex-1 min-w-0`,children:f}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>p(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,"aria-label":`关闭`,children:`✕`})]}):null,b?(0,C.jsxs)(`div`,{className:`mb-3 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-700 flex items-start gap-2`,children:[(0,C.jsx)(`span`,{className:`flex-1 min-w-0`,children:b}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>w(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-emerald-700/70 hover:bg-emerald-100 hover:text-emerald-900`,"aria-label":`关闭`,children:`✕`})]}):null,G.length?(0,C.jsxs)(`div`,{className:`mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2.5`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-amber-800`,children:v(`space.candidatesTitle`,{n:G.length})}),(0,C.jsx)(`p`,{className:`mt-1 text-[11px] leading-snug text-amber-700/90`,children:v(`space.candidatesHint`)}),(0,C.jsx)(`div`,{className:`mt-2 max-h-44 overflow-auto rounded-md border border-amber-200/70 bg-white divide-y divide-stone-100`,children:G.map(e=>(0,C.jsxs)(`label`,{className:`flex items-start gap-2 px-2.5 py-1.5 cursor-pointer hover:bg-stone-50`,children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:Te[e.path]===!0,onChange:t=>q(n=>({...n,[e.path]:t.target.checked})),className:`mt-0.5 accent-[#4176e6]`}),(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`span`,{className:`block text-xs text-stone-800 truncate`,children:e.name}),(0,C.jsx)(`span`,{className:`block text-[10px] text-stone-400 truncate font-mono`,children:Q?x(e.path,Q):e.path})]})]},e.path))}),(0,C.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>q(Object.fromEntries(G.map(e=>[e.path,!0]))),className:`text-[11px] text-[#4176e6] hover:underline`,children:v(`space.candidatesSelectAll`)}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>q({}),className:`text-[11px] text-stone-500 hover:underline`,children:v(`space.candidatesClear`)}),(0,C.jsx)(`span`,{className:`flex-1`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>{K([]),q({}),w(v(`space.candidatesIgnored`))},className:`px-2.5 py-1 text-[11px] rounded-md border border-stone-200 text-stone-600 hover:bg-stone-50`,children:v(`space.candidatesIgnore`)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Ve(),className:`px-2.5 py-1 text-[11px] rounded-md bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:opacity-40`,children:v(`space.candidatesAdopt`)})]})]}):null,T?(0,C.jsxs)(`div`,{ref:De,children:[(0,C.jsxs)(`div`,{className:`mb-2`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:v(`space.newTitle`)}),(0,C.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-stone-400`,children:v(`space.newDesc`)})]}),(0,C.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,C.jsx)(`input`,{autoFocus:!0,value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Pe())},placeholder:v(`space.namePlaceholder`),className:`w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`})}),a?(0,C.jsx)(`div`,{className:`mt-1.5 text-[11px] text-stone-400 truncate`,children:(0,C.jsx)(`code`,{children:x(a.dataRoot,a.baseRoot)})}):null,(0,C.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:v(`space.promptBriefLabel`)}),(0,C.jsx)(_e,{value:k,onChange:A,onGenerate:()=>void Me(`create`),onStop:X,generating:Ke,disabled:$}),(0,C.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,C.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:v(`space.promptHint`)}),Ke?(0,C.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[v(`space.promptGeneratingStatus`),(0,C.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,C.jsx)(ve,{value:j,onChange:ye,disabled:$})]})]}):M?(0,C.jsxs)(`div`,{ref:Oe,children:[(0,C.jsxs)(`div`,{className:`mb-2`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:v(`space.editTitle`)}),(0,C.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-stone-400 font-mono truncate`,children:Q?x(M.path,Q):M.path})]}),(0,C.jsxs)(`label`,{className:`block text-xs font-medium text-stone-500`,children:[v(`space.nameLabel`),(0,C.jsx)(`input`,{autoFocus:!0,value:P,disabled:z||M.isPublic===!0,onChange:e=>F(e.target.value),className:`mt-1.5 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors disabled:bg-stone-50 disabled:text-stone-400`})]}),M.isPublic?(0,C.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:v(`space.publicNameLocked`)}):null,(0,C.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:v(`space.promptBriefLabel`)}),(0,C.jsx)(_e,{value:I,onChange:e=>{L(e),Ce(!1)},onGenerate:()=>void Me(`edit`),onStop:X,generating:qe,disabled:$||z}),(0,C.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,C.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:v(`space.promptBriefHint`)}),qe?(0,C.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[v(`space.promptGeneratingStatus`),(0,C.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,C.jsx)(ve,{value:be,onChange:R,disabled:$||z,hint:v(`space.promptEditHint`)}),z?(0,C.jsx)(`p`,{className:`mt-2 text-[11px] text-stone-400`,children:v(`space.loading`)}):null]})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,C.jsxs)(`div`,{className:`text-xs font-medium text-stone-500`,children:[v(`space.listTitle`),Z.length?(0,C.jsx)(`span`,{className:`ml-1.5 text-[11px] text-stone-400 tabular-nums`,children:Z.length}):null]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>Ee.current?.click(),className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:u===`import`?`…`:v(`space.import`)}),(0,C.jsx)(`input`,{ref:Ee,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:e=>void He(e)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Be(),"data-hint":v(`space.discoverTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:v(u===`discover`?`space.discovering`:`space.discover`)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Y(!0),"data-hint":v(`space.sizeTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:v(u===`stats`?`space.sizing`:`space.size`)})]})]}),(0,C.jsx)(`div`,{className:`rounded-lg border border-stone-200 divide-y divide-stone-100 overflow-hidden`,children:Z.length===0?(0,C.jsx)(`div`,{className:`px-3 py-8 text-center text-xs text-stone-400`,children:v(`space.empty`)}):Ge.map(e=>(0,C.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,C.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:y(e)}),e.isPublic?(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500`,children:v(`space.builtin`)}):null,e.isActive?(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-[#4176e6]/10 text-[#3565c7]`,children:v(`space.activeTag`)}):null,e.exists?null:(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-amber-50 text-amber-600`,children:v(`space.missing`)}),e.bytes==null?null:(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500 tabular-nums`,children:ae(e.bytes)})]}),(0,C.jsx)(`div`,{className:`mt-0.5 text-[11px] text-stone-400 truncate cursor-help hover:text-stone-500`,"data-hint":Q?x(e.path,Q):e.path,"data-hint-always":``,children:Q?x(e.path,Q):e.path})]}),(0,C.jsxs)(`div`,{className:`shrink-0 flex flex-wrap justify-end items-center gap-1`,children:[!e.isActive&&e.exists?(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Le(e),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:v(`space.switch`)}):null,(0,C.jsx)(`button`,{type:`button`,disabled:$||!e.exists,onClick:()=>void Fe(e),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:v(`space.edit`)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{U(e),we(`${e.name}-copy`)},className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:v(`space.copy`)}),(0,C.jsx)(`a`,{href:ue(e.id,`content`),"data-hint":v(`space.exportContentTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:v(`space.exportContent`)}),(0,C.jsx)(`a`,{href:ue(e.id,`full`),"data-hint":v(`space.exportFullTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:v(`space.exportFull`)}),(0,C.jsx)(ge,{hint:e.removable?void 0:v(`space.publicLocked`),children:(0,C.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>V({kind:`remove`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:v(`space.removeList`)})}),(0,C.jsx)(ge,{hint:e.removable?void 0:v(`space.publicLocked`),children:(0,C.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>V({kind:`delete`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-red-200 text-red-600 hover:bg-red-50 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:v(`space.deleteDisk`)})})]})]},e.id))})]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-3 border-t border-stone-200`,children:[(0,C.jsx)(`button`,{type:`button`,disabled:$||T||M!==null,onClick:()=>{!T&&M===null&&Ne()},className:`h-8 px-3 text-xs font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-[#4176e6] transition-colors`,children:v(`space.addNew`)}),(0,C.jsx)(`span`,{className:`flex-1`}),T||M?(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{X(),E(!1),N(null)},className:`tw-confirm-cancel h-8 px-4 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-40 transition-colors`,children:v(`space.cancel`)}):null,T?(0,C.jsx)(`button`,{type:`button`,disabled:!D.trim()||$,onClick:()=>void Pe(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`create`?`…`:v(`space.create`)}):M?(0,C.jsx)(`button`,{type:`button`,disabled:!P.trim()||$||z,onClick:()=>void Ie(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`update`?`…`:v(`space.save`)}):null]})]})})]}),(0,C.jsxs)(c,{open:H!==null,onClose:()=>U(null),transition:!0,className:`relative z-96`,children:[(0,C.jsx)(l,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,C.jsxs)(o,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,C.jsx)(s,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:v(`space.confirmCopyTitle`)}),(0,C.jsx)(`p`,{className:`tw-confirm-msg mt-3 text-sm text-stone-600 leading-relaxed`,children:v(`space.confirmCopyMsg`,{name:H?.name??``})}),(0,C.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-stone-500`,children:[v(`space.copyName`),(0,C.jsx)(`input`,{autoFocus:!0,value:W,onChange:e=>we(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Re())},className:`mt-1.5 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`})]}),(0,C.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>U(null),className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 transition-colors`,children:v(`space.cancel`)}),(0,C.jsx)(`button`,{type:`button`,disabled:!W.trim()||$,onClick:()=>void Re(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`copy`?`…`:v(`space.copy`)})]})]})})]}),(0,C.jsx)(m,{open:B?.kind===`remove`,title:v(`space.confirmRemoveTitle`),message:B?.kind===`remove`?v(`space.confirmRemoveMsg`,{name:B.space.name,path:B.space.path}):``,confirmLabel:v(`space.removeList`),onClose:()=>V(null),onConfirm:()=>{B?.kind===`remove`&&ze(B.space,!1)}}),(0,C.jsx)(m,{open:B?.kind===`delete`,title:v(`space.confirmDeleteTitle`),message:B?.kind===`delete`?v(`space.confirmDeleteMsg`,{name:B.space.name,path:B.space.path}):``,confirmLabel:v(`space.deleteDisk`),danger:`solid`,onClose:()=>V(null),onConfirm:()=>{B?.kind===`delete`&&ze(B.space,!0)}})]})}var T=`tw.spaces.list.v1`;async function E(){let e=n(window.location.pathname,`/`);if(!e?.plugin)return!0;try{let t=await fetch(`/__tb_config`,{signal:AbortSignal.timeout(1500)});if(!t.ok)return!0;let n=await t.json();return a(n.config?.plugins??{})[e.plugin]!==!1}catch{return!0}}function D(){try{let e=sessionStorage.getItem(T);if(!e)return null;let t=JSON.parse(e);return t&&Array.isArray(t.spaces)?t:null}catch{return null}}function O(e){try{sessionStorage.setItem(T,JSON.stringify(e))}catch{}}function k(e){try{e?document.documentElement.dataset.spaceService=`none`:delete document.documentElement.dataset.spaceService}catch{}}function A(){let e=D(),[t,n]=(0,S.useState)(e!==null),[r,i]=(0,S.useState)(e!==null),[a,o]=(0,S.useState)(e),[s,c]=(0,S.useState)(!1),[l,p]=(0,S.useState)(!1),[m,h]=(0,S.useState)(``);(0,S.useEffect)(()=>{let e=!0;return(async()=>{let t=await b();if(!e)return;if(i(!0),!t){n(!1),k(!0);return}k(!1),n(!0);let r=await re();e&&r&&(o(r),O(r))})(),()=>{e=!1}},[]);async function te(e){if(e===a?.activeId)return;p(!0),h(``);let t=await ce(e);t.ok?(a&&O({...a,activeId:e,spaces:a.spaces.map(t=>({...t,isActive:t.id===e}))}),await E()?window.location.reload():window.location.replace(`/`)):(p(!1),h(t.error||`切换失败`))}if(!r)return null;if(!t)return(0,C.jsx)(`div`,{className:`tw-nav-space`,children:(0,C.jsxs)(`div`,{className:`tw-nav-space-btn tw-nav-space-btn--off`,children:[(0,C.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,C.jsx)(j,{})}),(0,C.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,C.jsx)(`span`,{className:`tw-nav-space-cap`,children:v(`space.offlineCap`)}),(0,C.jsx)(`span`,{className:`tw-nav-space-name`,children:v(`space.offline`)})]})]})});let g=a?.spaces.find(e=>e.isActive),_=(a?.spaces??[]).filter(e=>!e.isActive);return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`div`,{className:`tw-nav-space`,children:(0,C.jsxs)(d,{as:`div`,className:`tw-nav-space-menu`,children:[(0,C.jsxs)(f,{className:`tw-nav-space-btn`,"data-hint":v(`space.label`),children:[(0,C.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,C.jsx)(j,{})}),(0,C.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,C.jsx)(`span`,{className:`tw-nav-space-cap`,children:v(`space.current`)}),(0,C.jsx)(`span`,{className:`tw-nav-space-name`,children:l?v(`space.switching`):g?y(g):`—`})]}),(0,C.jsx)(`svg`,{className:`tw-nav-space-caret`,viewBox:`0 0 24 24`,width:`13`,height:`13`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,C.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),(0,C.jsxs)(ee,{transition:!0,anchor:{to:`bottom start`,gap:`0.375rem`},className:`tw-nav-space-pop tw-menu-anim`,children:[m?(0,C.jsx)(`div`,{className:`tw-nav-space-err`,role:`alert`,children:m}):null,(0,C.jsx)(`div`,{className:`tw-nav-space-group`,children:v(`space.others`)}),_.length===0?(0,C.jsx)(`p`,{className:`tw-nav-space-hint`,children:v(`space.othersEmpty`)}):_.map(e=>(0,C.jsx)(u,{children:(0,C.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item`,disabled:l,onClick:()=>void te(e.id),children:[(0,C.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,C.jsx)(`span`,{className:`tw-nav-space-item-name`,"data-hint":y(e),children:y(e)})}),(0,C.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,C.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})},e.id)),(0,C.jsx)(`div`,{className:`tw-nav-space-sep`}),(0,C.jsx)(u,{children:(0,C.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item tw-nav-space-item--manage`,onClick:()=>c(!0),children:[(0,C.jsx)(`span`,{className:`tw-nav-space-item-ico`,"aria-hidden":`true`,children:(0,C.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,C.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,C.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]})}),(0,C.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,C.jsx)(`span`,{className:`tw-nav-space-item-name`,children:v(`space.manage`)})}),(0,C.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,C.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})})]})]})}),(0,C.jsx)(w,{open:s,onClose:()=>c(!1),onListChanged:e=>{o(e),O(e)}})]})}function j(){return(0,C.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`15`,height:`15`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,C.jsx)(`path`,{d:`M3 7.5 12 3l9 4.5-9 4.5-9-4.5Z`}),(0,C.jsx)(`path`,{d:`m3 12.5 9 4.5 9-4.5`}),(0,C.jsx)(`path`,{d:`m3 17 9 4.5 9-4.5`})]})}export{A as default};
@@ -1 +1 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.huKxSIlN.js";import{a as r,o as i,r as a}from"./plugins.DaDJq-mn.js";import{a as o,n as s,o as c,r as l}from"./view-prefs.Dhdh8Z5a.js";import{i as u,n as d,r as f,t as p}from"./dialog.DXHznyjD.js";import{t as m}from"./jsx-runtime.BUXbF_vF.js";import{t as h}from"./ConfirmDialog.CBVsDJ8f.js";import{n as g,t as _}from"./ColumnResize.Bs6GL3DJ.js";import{t as v}from"./DatePicker.CMfX7F6z.js";import{t as y}from"./SelectDropdown.Buv7rQJ_.js";import{A as b,C as x,D as S,P as ee,a as C,b as w,c as T,f as te,g as E,h as ne,i as D,m as O,n as k,o as re,p as ie,r as ae,s as oe,t as A,u as se}from"./tasks.otRBFydq.js";import{a as j,l as M,n as N,o as P,r as F,s as I,t as L}from"./DrawerField.CWMLhcPX.js";var R=e(t(),1),z=m(),ce=8e3,B=[{key:`title`,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`action`,width:56,min:52}],le={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},ue={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},V={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},H={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},U={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},de=ae.map(e=>({value:e,label:D[e]})),fe=[{value:``,label:`未设置`},...A.map(e=>({value:e,label:k[e]}))],pe=[{value:`all`,label:`全部优先级`},...A.map(e=>({value:e,label:k[e]}))],me=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],he=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],ge=`tasks.status-tab`,_e=`tasks.priority-filter`,ve=`tasks.search`,ye=pe.map(e=>e.value);function W(e){return(0,z.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,z.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,z.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function be(e){let{open:t,task:n,todos:r,onClose:i,onSaved:a}=e,[o,s]=(0,R.useState)({title:``}),[c,l]=(0,R.useState)(``),[m,h]=(0,R.useState)(!1);(0,R.useEffect)(()=>{t&&(l(``),h(!1),s(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:b(),dueDate:b()}))},[t,n]);function g(e){s(t=>({...t,...e}))}let _=O({startDate:o.startDate??``,dueDate:o.dueDate??``}),y=n?r.filter(e=>e.taskId===n.id):[],S=y.filter(e=>e.status===`done`).length,ee=y.length?Math.round(S/y.length*100):0;async function T(){let e=(o.title??``).trim();if(!e)l(`请填写任务名称`);else if(o.startDate&&o.dueDate&&o.dueDate<o.startDate)l(`截止日期不能早于开始日期`);else{h(!0),l(``);try{n?await E(n.id,o):await C([{...o,title:e}],{mode:`manual`}),await a(),i()}catch(e){l(e instanceof Error?e.message:String(e))}finally{h(!1)}}}return(0,z.jsxs)(f,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,z.jsx)(p,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,z.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,z.jsxs)(u,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,z.jsx)(d,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,z.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`任务名称`,children:(0,z.jsx)(`input`,{autoFocus:!0,value:o.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},placeholder:`请输入内容`,className:L})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`任务状态`,children:(0,z.jsx)(F,{ariaLabel:`任务状态`,menuMinWidth:140,options:de,value:o.status??`pool`,onChange:e=>g({status:e}),label:D[o.status??`pool`],optionDotClassName:e=>H[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`紧急程度`,children:(0,z.jsx)(F,{ariaLabel:`紧急程度`,menuMinWidth:140,options:fe,value:o.priority??``,onChange:e=>g({priority:e}),label:o.priority?k[o.priority]:`未设置`,optionDotClassName:e=>U[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`开始日期`,children:(0,z.jsx)(v,{value:o.startDate??``,onChange:e=>g({startDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`截止日期`,children:(0,z.jsx)(v,{value:o.dueDate??``,onChange:e=>g({dueDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`任务周期`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_===null?`—`:`${_} 天`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`待办进度`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:y.length?`${S}/${y.length} · ${ee}%`:`还没有关联待办`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`备注`,children:(0,z.jsx)(`textarea`,{value:o.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&y.length?(0,z.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,z.jsx)(`ul`,{className:`space-y-1.5`,children:y.map(e=>{let t=x(e,b());return(0,z.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,z.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${V[t]}`,children:w[t]})]},e.id)})})]}):null,c?(0,z.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:c}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:i,disabled:m,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:m,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:m?`保存中…`:n?`保存`:`新建`})]})]})})]})}function xe(){let[e,t]=(0,R.useState)(!1),[u,d]=(0,R.useState)(!0),[f,p]=(0,R.useState)(!0),[m,b]=(0,R.useState)(null),[x,C]=(0,R.useState)([]),[w,ae]=(0,R.useState)([]),[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(!1),[P,F]=(0,R.useState)(()=>l(ve)),[I,L]=(0,R.useState)(()=>s(ge,he,`all`)),[V,xe]=(0,R.useState)(()=>s(_e,ye,`all`)),[Se,G]=(0,R.useState)(null),[K,q]=(0,R.useState)(null);function Ce(e){o(ge,e),L(e)}function we(e){c(ve,e),F(e)}function Te(e){o(_e,e),xe(e)}let J=(0,R.useRef)(!0),Y=g(`lh:tasks:cols:v1`,B);(0,R.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,R.useCallback)(async()=>{try{let[e,t]=await Promise.all([se(),f?S().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;C(e),ae(t),j(null)}catch(e){if(!J.current)return;j(e instanceof Error?e.message:String(e))}},[f]);(0,R.useEffect)(()=>{let e=r(e=>{d(!!e.tasks),p(!!e.todos)});return n().then(()=>{d(a(`tasks`)),p(a(`todos`)),t(!0)}),e},[]),(0,R.useEffect)(()=>{e&&u&&(async()=>{let e=await oe();J.current&&(e?(await X(),J.current&&b(!0)):b(!1))})()},[e,u,X]),(0,R.useEffect)(()=>{if(m!==!0)return;let e=window.setInterval(()=>void X(),ce),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[m,X]);let Ee=(0,R.useMemo)(()=>ne(w),[w]),Z=(0,R.useMemo)(()=>ie(x),[x]),De=(0,R.useMemo)(()=>T(x,{status:I,priority:V,keyword:P}),[x,I,V,P]),Q=(0,R.useMemo)(()=>te(De),[De]);async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await E(e,t);if(!J.current)return;C(t=>t.map(t=>t.id===e?n:t)),j(null)}catch(e){j(e instanceof Error?e.message:String(e)),await X()}}async function Oe(){let e=K;if(e){q(null),N(!0);try{await re([e.id]),await Promise.all(w.filter(t=>t.taskId===e.id).map(e=>ee(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X()}catch(e){j(e instanceof Error?e.message:String(e))}finally{J.current&&N(!1)}}}return e?u?m===null?(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):m?(0,z.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,z.jsx)(W,{label:`全部任务`,value:Z.total}),(0,z.jsx)(W,{label:`任务池`,value:Z.pool}),(0,z.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,z.jsx)(W,{label:`已完成`,value:Z.done}),(0,z.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,z.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,z.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,z.jsx)(`input`,{value:P,onChange:e=>we(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,z.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:me.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>Ce(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${I===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,z.jsx)(y,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:pe,value:V,onChange:e=>Te(e)}),(0,z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,z.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),A?(0,z.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1`,children:A}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>j(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,z.jsxs)(`table`,{className:`tw-task-table w-full table-fixed border-collapse text-sm`,style:Y.tableStyle,children:[(0,z.jsx)(`colgroup`,{children:B.map(e=>(0,z.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,z.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsxs)(`th`,{className:`relative px-3 py-2 text-left font-medium whitespace-nowrap`,children:[`任务描述`,(0,z.jsx)(_,{...Y.resizeProps(0)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,z.jsx)(_,{...Y.resizeProps(1)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,z.jsx)(_,{...Y.resizeProps(2)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,z.jsx)(_,{...Y.resizeProps(3)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,z.jsx)(_,{...Y.resizeProps(4)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,z.jsx)(_,{...Y.resizeProps(5)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,z.jsx)(_,{...Y.resizeProps(6)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,z.jsx)(_,{...Y.resizeProps(7)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,z.jsx)(_,{...Y.resizeProps(8)})]}),(0,z.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,z.jsxs)(`tbody`,{children:[Q.map(e=>{let t=O(e),n=Ee[e.id]??{total:0,done:0,percent:0};return(0,z.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,z.jsx)(`td`,{className:`px-3 py-1 align-middle`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,z.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:de,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${le[e.status]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:D[e.status]}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${H[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:fe,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ue[e.priority]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?k[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${U[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:f?n.total?`${n.total} 条`:`0`:(0,z.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:f?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,z.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,z.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,z.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,z.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M14 4h6v6`}),(0,z.jsx)(`path`,{d:`M20 4 13 11`}),(0,z.jsx)(`path`,{d:`M10 20H4v-6`}),(0,z.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M3 6h18`}),(0,z.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,z.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,z.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:10,className:`px-3 py-16 text-center text-sm text-stone-400`,children:x.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,z.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,z.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,z.jsx)(be,{open:Se!==null,task:Se?.task??null,todos:w,onClose:()=>G(null),onSaved:X}),(0,z.jsx)(h,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Oe()})]}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`tasks`)}):(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{xe as default};
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DKMxjv3g.js";import{a as r,o as i,r as a}from"./plugins.D5ypJIXn.js";import{a as o,n as s,o as c,r as l}from"./view-prefs.HCowOWXL.js";import{i as u,n as d,r as f,t as p}from"./dialog.DXHznyjD.js";import{t as m}from"./jsx-runtime.BUXbF_vF.js";import{t as h}from"./ConfirmDialog.CBVsDJ8f.js";import{n as g,t as _}from"./ColumnResize.Bs6GL3DJ.js";import{t as v}from"./DatePicker.CMfX7F6z.js";import{t as y}from"./SelectDropdown.Buv7rQJ_.js";import{A as b,C as x,D as S,P as ee,a as C,b as w,c as T,f as te,g as E,h as ne,i as D,m as O,n as k,o as re,p as ie,r as ae,s as oe,t as A,u as se}from"./tasks.otRBFydq.js";import{a as j,l as M,n as N,o as P,r as F,s as I,t as L}from"./DrawerField.CWMLhcPX.js";var R=e(t(),1),z=m(),ce=8e3,B=[{key:`title`,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`action`,width:56,min:52}],le={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},ue={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},V={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},H={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},U={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},de=ae.map(e=>({value:e,label:D[e]})),fe=[{value:``,label:`未设置`},...A.map(e=>({value:e,label:k[e]}))],pe=[{value:`all`,label:`全部优先级`},...A.map(e=>({value:e,label:k[e]}))],me=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],he=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],ge=`tasks.status-tab`,_e=`tasks.priority-filter`,ve=`tasks.search`,ye=pe.map(e=>e.value);function W(e){return(0,z.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,z.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,z.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function be(e){let{open:t,task:n,todos:r,onClose:i,onSaved:a}=e,[o,s]=(0,R.useState)({title:``}),[c,l]=(0,R.useState)(``),[m,h]=(0,R.useState)(!1);(0,R.useEffect)(()=>{t&&(l(``),h(!1),s(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:b(),dueDate:b()}))},[t,n]);function g(e){s(t=>({...t,...e}))}let _=O({startDate:o.startDate??``,dueDate:o.dueDate??``}),y=n?r.filter(e=>e.taskId===n.id):[],S=y.filter(e=>e.status===`done`).length,ee=y.length?Math.round(S/y.length*100):0;async function T(){let e=(o.title??``).trim();if(!e)l(`请填写任务名称`);else if(o.startDate&&o.dueDate&&o.dueDate<o.startDate)l(`截止日期不能早于开始日期`);else{h(!0),l(``);try{n?await E(n.id,o):await C([{...o,title:e}],{mode:`manual`}),await a(),i()}catch(e){l(e instanceof Error?e.message:String(e))}finally{h(!1)}}}return(0,z.jsxs)(f,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,z.jsx)(p,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,z.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,z.jsxs)(u,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,z.jsx)(d,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,z.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`任务名称`,children:(0,z.jsx)(`input`,{autoFocus:!0,value:o.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},placeholder:`请输入内容`,className:L})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`任务状态`,children:(0,z.jsx)(F,{ariaLabel:`任务状态`,menuMinWidth:140,options:de,value:o.status??`pool`,onChange:e=>g({status:e}),label:D[o.status??`pool`],optionDotClassName:e=>H[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(I,{}),label:`紧急程度`,children:(0,z.jsx)(F,{ariaLabel:`紧急程度`,menuMinWidth:140,options:fe,value:o.priority??``,onChange:e=>g({priority:e}),label:o.priority?k[o.priority]:`未设置`,optionDotClassName:e=>U[e]})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`开始日期`,children:(0,z.jsx)(v,{value:o.startDate??``,onChange:e=>g({startDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(j,{}),label:`截止日期`,children:(0,z.jsx)(v,{value:o.dueDate??``,onChange:e=>g({dueDate:e}),className:`${L} tabular-nums`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`任务周期`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_===null?`—`:`${_} 天`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(P,{}),label:`待办进度`,children:(0,z.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:y.length?`${S}/${y.length} · ${ee}%`:`还没有关联待办`})}),(0,z.jsx)(N,{icon:(0,z.jsx)(M,{}),label:`备注`,children:(0,z.jsx)(`textarea`,{value:o.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&y.length?(0,z.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,z.jsx)(`ul`,{className:`space-y-1.5`,children:y.map(e=>{let t=x(e,b());return(0,z.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,z.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${V[t]}`,children:w[t]})]},e.id)})})]}):null,c?(0,z.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:c}):null]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:i,disabled:m,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void T(),disabled:m,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:m?`保存中…`:n?`保存`:`新建`})]})]})})]})}function xe(){let[e,t]=(0,R.useState)(!1),[u,d]=(0,R.useState)(!0),[f,p]=(0,R.useState)(!0),[m,b]=(0,R.useState)(null),[x,C]=(0,R.useState)([]),[w,ae]=(0,R.useState)([]),[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(!1),[P,F]=(0,R.useState)(()=>l(ve)),[I,L]=(0,R.useState)(()=>s(ge,he,`all`)),[V,xe]=(0,R.useState)(()=>s(_e,ye,`all`)),[Se,G]=(0,R.useState)(null),[K,q]=(0,R.useState)(null);function Ce(e){o(ge,e),L(e)}function we(e){c(ve,e),F(e)}function Te(e){o(_e,e),xe(e)}let J=(0,R.useRef)(!0),Y=g(`lh:tasks:cols:v1`,B);(0,R.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,R.useCallback)(async()=>{try{let[e,t]=await Promise.all([se(),f?S().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;C(e),ae(t),j(null)}catch(e){if(!J.current)return;j(e instanceof Error?e.message:String(e))}},[f]);(0,R.useEffect)(()=>{let e=r(e=>{d(!!e.tasks),p(!!e.todos)});return n().then(()=>{d(a(`tasks`)),p(a(`todos`)),t(!0)}),e},[]),(0,R.useEffect)(()=>{e&&u&&(async()=>{let e=await oe();J.current&&(e?(await X(),J.current&&b(!0)):b(!1))})()},[e,u,X]),(0,R.useEffect)(()=>{if(m!==!0)return;let e=window.setInterval(()=>void X(),ce),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[m,X]);let Ee=(0,R.useMemo)(()=>ne(w),[w]),Z=(0,R.useMemo)(()=>ie(x),[x]),De=(0,R.useMemo)(()=>T(x,{status:I,priority:V,keyword:P}),[x,I,V,P]),Q=(0,R.useMemo)(()=>te(De),[De]);async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await E(e,t);if(!J.current)return;C(t=>t.map(t=>t.id===e?n:t)),j(null)}catch(e){j(e instanceof Error?e.message:String(e)),await X()}}async function Oe(){let e=K;if(e){q(null),N(!0);try{await re([e.id]),await Promise.all(w.filter(t=>t.taskId===e.id).map(e=>ee(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X()}catch(e){j(e instanceof Error?e.message:String(e))}finally{J.current&&N(!1)}}}return e?u?m===null?(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):m?(0,z.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,z.jsx)(W,{label:`全部任务`,value:Z.total}),(0,z.jsx)(W,{label:`任务池`,value:Z.pool}),(0,z.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,z.jsx)(W,{label:`已完成`,value:Z.done}),(0,z.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,z.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,z.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,z.jsx)(`input`,{value:P,onChange:e=>we(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,z.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:me.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>Ce(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${I===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,z.jsx)(y,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:pe,value:V,onChange:e=>Te(e)}),(0,z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,z.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),A?(0,z.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1`,children:A}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>j(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,z.jsxs)(`table`,{className:`tw-task-table w-full table-fixed border-collapse text-sm`,style:Y.tableStyle,children:[(0,z.jsx)(`colgroup`,{children:B.map(e=>(0,z.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,z.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsxs)(`th`,{className:`relative px-3 py-2 text-left font-medium whitespace-nowrap`,children:[`任务描述`,(0,z.jsx)(_,{...Y.resizeProps(0)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,z.jsx)(_,{...Y.resizeProps(1)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,z.jsx)(_,{...Y.resizeProps(2)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,z.jsx)(_,{...Y.resizeProps(3)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,z.jsx)(_,{...Y.resizeProps(4)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,z.jsx)(_,{...Y.resizeProps(5)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,z.jsx)(_,{...Y.resizeProps(6)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,z.jsx)(_,{...Y.resizeProps(7)})]}),(0,z.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,z.jsx)(_,{...Y.resizeProps(8)})]}),(0,z.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,z.jsxs)(`tbody`,{children:[Q.map(e=>{let t=O(e),n=Ee[e.id]??{total:0,done:0,percent:0};return(0,z.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,z.jsx)(`td`,{className:`px-3 py-1 align-middle`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,z.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:de,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${le[e.status]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:D[e.status]}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${H[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,z.jsx)(y,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:fe,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ue[e.priority]}`,renderTrigger:()=>(0,z.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?k[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full ${U[e.value]}`})})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,z.jsx)(v,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:f?n.total?`${n.total} 条`:`0`:(0,z.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:f?(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,z.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,z.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,z.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,z.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,z.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M14 4h6v6`}),(0,z.jsx)(`path`,{d:`M20 4 13 11`}),(0,z.jsx)(`path`,{d:`M10 20H4v-6`}),(0,z.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,z.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,z.jsx)(`path`,{d:`M3 6h18`}),(0,z.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,z.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,z.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{colSpan:10,className:`px-3 py-16 text-center text-sm text-stone-400`,children:x.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,z.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,z.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,z.jsx)(be,{open:Se!==null,task:Se?.task??null,todos:w,onClose:()=>G(null),onSaved:X}),(0,z.jsx)(h,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Oe()})]}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,z.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`tasks`)}):(0,z.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,z.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{xe as default};
@@ -1 +1 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.huKxSIlN.js";import{a as r,o as i,r as a}from"./plugins.DaDJq-mn.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as s}from"./ConfirmDialog.CBVsDJ8f.js";import{n as c,t as ee}from"./DocsPager.BARD7JvD.js";import{a as l,i as u,r as d,t as te}from"./ExcelFieldTags.B_XMwNNx.js";import{a as ne,c as re,d as f,f as p,h as ie,i as ae,l as oe,m as se,n as ce,o as le,p as ue,r as de,s as m,t as fe,u as pe}from"./project-docs.Cd2gKPKh.js";import{n as me}from"./doc-roots.DAJP9Svr.js";import{t as he}from"./useListAnim.CpGB1cft.js";import{t as h}from"./NamePromptDialog.Dl5kSnQI.js";var g=e(t(),1),_=o(),v=5;async function ge(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await f(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return l(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await p(`templates`,e.path);return d(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await p(`templates`,e.path);return u(t.content).headers}}catch{}return[]}function y({className:e=`w-4 h-4`,open:t=!1}){return(0,_.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,_.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,_.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function b({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,_.jsx)(`path`,{d:`m15 5 4 4`})]})}function x({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M3 6h18`}),(0,_.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,_.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,_.jsx)(`path`,{d:`M10 11v6`}),(0,_.jsx)(`path`,{d:`M14 11v6`})]})}function S({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(y,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:e.children.map(e=>(0,_.jsx)(S,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function _e(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function C(){let[e,t]=(0,g.useState)(()=>a(`templates`)),[o,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)([]),[C,ve]=(0,g.useState)(0),[w,T]=(0,g.useState)(`.`),[E,D]=(0,g.useState)([]),[ye,be]=(0,g.useState)({}),[xe,O]=(0,g.useState)({}),[k,Se]=(0,g.useState)(!0),[A,j]=(0,g.useState)(null),[M,N]=(0,g.useState)(!1),[Ce,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(null),[z,B]=(0,g.useState)(1),[V,we]=c(v),[Te,H]=(0,g.useState)(null),U=(0,g.useRef)(null),{cls:Ee,play:W}=he(),G=(0,g.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await ge(e);n.length&&(t[e.path]=n)})),be(t)},[]),K=(0,g.useCallback)(async()=>{let e=await ae(`templates`);p(e.tree),ve(e.totalFiles)},[]),q=(0,g.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([m(`templates`,e),K()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await G(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,G,K]);(0,g.useEffect)(()=>{let e=r(e=>t(!!e.templates));return n().then(()=>{t(a(`templates`)),l(!0)}),e},[]),(0,g.useEffect)(()=>{o&&e&&(async()=>{let e=await de(`templates`);if(d(e),e)try{let[e]=await Promise.all([m(`templates`,`.`),K()]);D(e.entries),T(e.path),await G(e.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,G,K]);function De(){Se(e=>!e),O({})}async function J(e){W(),T(e),B(1),H(null),j(null);try{let t=await m(`templates`,e);D(t.entries),await G(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function Oe(e){P(!1),N(!0),j(null);try{await re(`templates`,w,e),await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ie(`templates`,w,t);await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1),U.current&&(U.current.value=``)}}}async function Ae(e){if(e.type===`file`){N(!0),j(null);try{await oe(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function je(e){let t=ne(f,e.path),n=t?.fileCount??0,r=t?fe(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Me(e){I({name:e.name,path:e.path,isDir:!1})}function Y(e,t){R({...e,isDir:t})}async function Ne(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await ce(`templates`,e.path);let t=le(w,e.path)?pe(e.path):w;await q(t)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Pe(e){let t=L;if(t&&(R(null),e!==t.name)){N(!0),j(null);try{let n=await se(`templates`,t.path,e);await q(ue(w,t.path,n))}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let Fe=(()=>{if(!F)return``;if(!F.isDir)return`删除文件「${F.name}」?将移入系统废纸篓,可随时找回。`;if(F.blocked){let e=[];return F.files&&e.push(`${F.files} 个文件`),F.dirs&&e.push(`${F.dirs} 个子文件夹`),`文件夹「${F.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${F.name}」?将移入系统废纸篓。`})();if(!o)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`templates`)});if(u===null)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!u)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`模板库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/V)),$=Math.min(z,Q),Ie=X.slice(($-1)*V,$*V);function Le(e){W(),we(e),B(1)}return(0,_.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,_.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1`,children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),De()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(y,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:f.map(e=>(0,_.jsx)(S,{node:e,depth:0,activePath:w,expanded:xe,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,_.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,_.jsx)(`span`,{className:`text-stone-400`,children:me(`templates`)}),w===`.`?``:w]}),(0,_.jsx)(`input`,{ref:U,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>U.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,_.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,_.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,_.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,_.jsx)(y,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,_.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,_.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加模板(.md / .xlsx / .docx 等)`}):(0,_.jsx)(`ul`,{className:`${Ee}space-y-1`,children:Ie.map(e=>{let t=ye[e.path]??[],n=Te===e.path;return(0,_.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>H(e.path),onDoubleClick:()=>void Ae(e),children:[(0,_.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,_.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:_e(e.size)}),t.length>0?(0,_.jsx)(te,{fields:t}):null]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Me(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,_.jsx)(ee,{page:$,totalPages:Q,pageSize:V,busy:M,onPage:e=>{W(),B(e)},onPageSize:Le}):null]}),(0,_.jsx)(h,{open:Ce,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void Oe(e)}),(0,_.jsx)(h,{open:L!=null,title:L?.isDir?`重命名文件夹`:`重命名文件`,label:L?.isDir?`文件夹名称`:`文件名称`,initialValue:L?.name??``,lockExtension:L!=null&&!L.isDir,confirmLabel:`保存`,onClose:()=>R(null),onConfirm:e=>void Pe(e)}),(0,_.jsx)(s,{open:F!=null,title:F?.blocked?`无法删除文件夹`:F?.isDir?`删除文件夹`:`删除模板`,message:Fe,confirmLabel:F?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!F?.blocked,hideCancel:!!F?.blocked,onClose:()=>I(null),onConfirm:()=>void Ne()})]})}export{C as default};
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DKMxjv3g.js";import{a as r,o as i,r as a}from"./plugins.D5ypJIXn.js";import{t as o}from"./jsx-runtime.BUXbF_vF.js";import{t as s}from"./ConfirmDialog.CBVsDJ8f.js";import{n as c,t as ee}from"./DocsPager.rzu4mnzw.js";import{a as l,i as u,r as d,t as te}from"./ExcelFieldTags.B_XMwNNx.js";import{a as ne,c as re,d as f,f as p,h as ie,i as ae,l as oe,m as se,n as ce,o as le,p as ue,r as de,s as m,t as fe,u as pe}from"./project-docs.Cd2gKPKh.js";import{n as me}from"./doc-roots.DAJP9Svr.js";import{t as he}from"./useListAnim.CpGB1cft.js";import{t as h}from"./NamePromptDialog.Dl5kSnQI.js";var g=e(t(),1),_=o(),v=5;async function ge(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await f(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return l(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await p(`templates`,e.path);return d(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await p(`templates`,e.path);return u(t.content).headers}}catch{}return[]}function y({className:e=`w-4 h-4`,open:t=!1}){return(0,_.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,_.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,_.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function b({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,_.jsx)(`path`,{d:`m15 5 4 4`})]})}function x({className:e=`w-3 h-3`}){return(0,_.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,_.jsx)(`path`,{d:`M3 6h18`}),(0,_.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,_.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,_.jsx)(`path`,{d:`M10 11v6`}),(0,_.jsx)(`path`,{d:`M14 11v6`})]})}function S({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,_.jsx)(y,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:e.children.map(e=>(0,_.jsx)(S,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function _e(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function C(){let[e,t]=(0,g.useState)(()=>a(`templates`)),[o,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)([]),[C,ve]=(0,g.useState)(0),[w,T]=(0,g.useState)(`.`),[E,D]=(0,g.useState)([]),[ye,be]=(0,g.useState)({}),[xe,O]=(0,g.useState)({}),[k,Se]=(0,g.useState)(!0),[A,j]=(0,g.useState)(null),[M,N]=(0,g.useState)(!1),[Ce,P]=(0,g.useState)(!1),[F,I]=(0,g.useState)(null),[L,R]=(0,g.useState)(null),[z,B]=(0,g.useState)(1),[V,we]=c(v),[Te,H]=(0,g.useState)(null),U=(0,g.useRef)(null),{cls:Ee,play:W}=he(),G=(0,g.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await ge(e);n.length&&(t[e.path]=n)})),be(t)},[]),K=(0,g.useCallback)(async()=>{let e=await ae(`templates`);p(e.tree),ve(e.totalFiles)},[]),q=(0,g.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([m(`templates`,e),K()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await G(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,G,K]);(0,g.useEffect)(()=>{let e=r(e=>t(!!e.templates));return n().then(()=>{t(a(`templates`)),l(!0)}),e},[]),(0,g.useEffect)(()=>{o&&e&&(async()=>{let e=await de(`templates`);if(d(e),e)try{let[e]=await Promise.all([m(`templates`,`.`),K()]);D(e.entries),T(e.path),await G(e.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,G,K]);function De(){Se(e=>!e),O({})}async function J(e){W(),T(e),B(1),H(null),j(null);try{let t=await m(`templates`,e);D(t.entries),await G(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function Oe(e){P(!1),N(!0),j(null);try{await re(`templates`,w,e),await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await ie(`templates`,w,t);await q(w)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1),U.current&&(U.current.value=``)}}}async function Ae(e){if(e.type===`file`){N(!0),j(null);try{await oe(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function je(e){let t=ne(f,e.path),n=t?.fileCount??0,r=t?fe(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function Me(e){I({name:e.name,path:e.path,isDir:!1})}function Y(e,t){R({...e,isDir:t})}async function Ne(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await ce(`templates`,e.path);let t=le(w,e.path)?pe(e.path):w;await q(t)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function Pe(e){let t=L;if(t&&(R(null),e!==t.name)){N(!0),j(null);try{let n=await se(`templates`,t.path,e);await q(ue(w,t.path,n))}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}let Fe=(()=>{if(!F)return``;if(!F.isDir)return`删除文件「${F.name}」?将移入系统废纸篓,可随时找回。`;if(F.blocked){let e=[];return F.files&&e.push(`${F.files} 个文件`),F.dirs&&e.push(`${F.dirs} 个子文件夹`),`文件夹「${F.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${F.name}」?将移入系统废纸篓。`})();if(!o)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`templates`)});if(u===null)return(0,_.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,_.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!u)return(0,_.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`模板库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/V)),$=Math.min(z,Q),Ie=X.slice(($-1)*V,$*V);function Le(e){W(),we(e),B(1)}return(0,_.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,_.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1`,children:[(0,_.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),De()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,_.jsx)(y,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,_.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,_.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,_.jsx)(`div`,{className:`tw-collapse-inner`,children:f.map(e=>(0,_.jsx)(S,{node:e,depth:0,activePath:w,expanded:xe,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,_.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,_.jsx)(`span`,{className:`text-stone-400`,children:me(`templates`)}),w===`.`?``:w]}),(0,_.jsx)(`input`,{ref:U,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,_.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>U.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,_.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,_.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,_.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,_.jsx)(y,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,_.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je({name:e.name,path:e.path}),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40`,children:(0,_.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,_.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加模板(.md / .xlsx / .docx 等)`}):(0,_.jsx)(`ul`,{className:`${Ee}space-y-1`,children:Ie.map(e=>{let t=ye[e.path]??[],n=Te===e.path;return(0,_.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>H(e.path),onDoubleClick:()=>void Ae(e),children:[(0,_.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,_.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:_e(e.size)}),t.length>0?(0,_.jsx)(te,{fields:t}):null]}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,_.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Me(e),className:`p-1.5 rounded text-red-600 hover:bg-red-50 disabled:opacity-40 shrink-0 mt-0.5`,children:(0,_.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,_.jsx)(ee,{page:$,totalPages:Q,pageSize:V,busy:M,onPage:e=>{W(),B(e)},onPageSize:Le}):null]}),(0,_.jsx)(h,{open:Ce,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void Oe(e)}),(0,_.jsx)(h,{open:L!=null,title:L?.isDir?`重命名文件夹`:`重命名文件`,label:L?.isDir?`文件夹名称`:`文件名称`,initialValue:L?.name??``,lockExtension:L!=null&&!L.isDir,confirmLabel:`保存`,onClose:()=>R(null),onConfirm:e=>void Pe(e)}),(0,_.jsx)(s,{open:F!=null,title:F?.blocked?`无法删除文件夹`:F?.isDir?`删除文件夹`:`删除模板`,message:Fe,confirmLabel:F?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!F?.blocked,hideCancel:!!F?.blocked,onClose:()=>I(null),onConfirm:()=>void Ne()})]})}export{C as default};
@@ -1 +1 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.huKxSIlN.js";import{a as r,o as i,r as a}from"./plugins.DaDJq-mn.js";import{o,r as ee}from"./view-prefs.Dhdh8Z5a.js";import{t as s}from"./jsx-runtime.BUXbF_vF.js";import{t as c}from"./ConfirmDialog.CBVsDJ8f.js";import{n as te,t as l}from"./ColumnResize.Bs6GL3DJ.js";import{t as ne}from"./DatePicker.CMfX7F6z.js";import{n as re,t as ie}from"./DocsPager.BARD7JvD.js";import{t as ae}from"./TagSelect.u8DTop7v.js";import{a as oe,c as u,i as d,l as f,n as se,o as ce,r as le,s as ue,t as de,u as fe}from"./test-stats.MEm3K2rB.js";var p=e(t(),1),m=s(),h=8e3,g=600,_=20,pe=`tw.test-stats.page-size.v1`,v=`test-stats.search`,y=[{key:`select`,width:32,min:28},{key:`index`,width:44,min:36},{key:`date`,width:140,min:120},{key:`dimensions`,min:240},{key:`count`,width:120,min:90},{key:`action`,width:64,min:56}],b=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,x=(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M3 6h18`}),(0,m.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,m.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,m.jsx)(`path`,{d:`M10 11v6M14 11v6`})]});function me(e){let[t,n]=(0,p.useState)(e.value?String(e.value):``),r=(0,p.useRef)(e.value),i=(0,p.useRef)(e.onCommit);i.current=e.onCommit,(0,p.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,p.useEffect)(()=>{let e=t?u(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},g);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?u(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,m.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:b})}function S(){let[e,t]=(0,p.useState)(!1),[s,u]=(0,p.useState)(!0),[g,b]=(0,p.useState)(null),[S,C]=(0,p.useState)([]),[w,T]=(0,p.useState)([]),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(!1),[A,j]=(0,p.useState)(()=>ee(v)),[M,N]=(0,p.useState)({}),[P,F]=(0,p.useState)(1),[I,L]=re(_,pe),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(null);function H(e){o(v,e),j(e),F(1)}let U=(0,p.useRef)(!0),W=(0,p.useRef)(!1),G=te(`lh:test-stats:cols:v1`,y);(0,p.useEffect)(()=>(U.current=!0,()=>{U.current=!1}),[]);let K=(0,p.useCallback)(async()=>{try{let e=await oe();if(!U.current)return;C(e.items),T(e.dimensions),N(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),D(null)}catch(e){if(!U.current)return;D(e instanceof Error?e.message:String(e))}},[]);(0,p.useEffect)(()=>{let e=r(e=>u(!!e.testStats));return n().then(()=>{u(a(`testStats`)),t(!0)}),e},[]),(0,p.useEffect)(()=>{e&&s&&(async()=>{let e=await le();U.current&&(e?(await K(),U.current&&b(!0)):b(!1))})()},[e,s,K]),(0,p.useEffect)(()=>{if(g!==!0)return;let e=window.setInterval(()=>{W.current||K()},h),t=()=>{W.current||K()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[g,K]);let he=f(),q=(0,p.useMemo)(()=>ce(d(S,{keyword:A})),[S,A]),J=(0,p.useMemo)(()=>ue(S),[S]),Y=Math.max(1,Math.ceil(q.length/I)),X=Math.min(P,Y),Z=(0,p.useMemo)(()=>q.slice((X-1)*I,X*I),[q,X,I]),Q=(0,p.useMemo)(()=>S.filter(e=>M[e.id]),[S,M]),ge=Z.length>0&&Z.every(e=>M[e.id]);(0,p.useEffect)(()=>{if(!R)return;let e=q.findIndex(e=>e.id===R);if(e<0)return;F(Math.floor(e/I)+1);let t=window.setTimeout(()=>z(null),2e3);return()=>window.clearTimeout(t)},[R,q,I]);async function _e(){if(!O){k(!0),D(null),H(``);try{let e=await de([{date:he,dimensions:[],count:0}],{mode:`manual`});if(!U.current)return;let t=e.items[0];if(e.dimensions.length&&T(e.dimensions),await K(),!U.current||!t)return;z(t.id)}catch(e){U.current&&D(e instanceof Error?e.message:String(e))}finally{U.current&&k(!1)}}}async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,dimensions:r}=await fe(e,t);if(!U.current)return;C(t=>t.map(t=>t.id===e?n:t)),r.length&&T(r),D(null)}catch(e){if(!U.current)return;D(e instanceof Error?e.message:String(e)),await K()}}async function ve(){let e=B;if(e&&e.length!==0){V(null),k(!0);try{if(await se(e.map(e=>e.id)),!U.current)return;N({}),D(null),await K()}catch(e){U.current&&D(e instanceof Error?e.message:String(e))}finally{U.current&&k(!1)}}}return e?s?g===null?(0,m.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接测试统计服务`,children:(0,m.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):g?(0,m.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,m.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,m.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,m.jsx)(`span`,{className:`font-medium text-stone-800`,children:J.records}),` 条`,(0,m.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 覆盖 `,J.dimensions,` 个维度 · 数量合计 `,J.total,Q.length?` · 已选 ${Q.length} 条`:``]})]}),(0,m.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,m.jsx)(`input`,{value:A,onChange:e=>H(e.target.value),placeholder:`搜索日期 / 维度…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,m.jsx)(`button`,{type:`button`,disabled:O||Q.length===0,onClick:()=>V(Q),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,m.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>void _e(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加记录`})]})]}),E?(0,m.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,m.jsx)(`span`,{className:`min-w-0 flex-1`,children:E}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>D(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,m.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{W.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{W.current=!!document.activeElement?.closest(`.tw-data-table`)},0)},children:(0,m.jsxs)(`table`,{className:`tw-data-table w-full table-fixed border-collapse text-sm`,style:G.tableStyle,children:[(0,m.jsx)(`colgroup`,{children:y.map(e=>(0,m.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,m.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,children:(0,m.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:ge,disabled:Z.length===0,onChange:e=>{let t=e.target.checked;N(e=>{let n={...e};for(let e of Z)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,m.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`行号`}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`当前日期`,(0,m.jsx)(l,{...G.resizeProps(2)})]}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`测试统计维度`,(0,m.jsx)(l,{...G.resizeProps(3)})]}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-center font-medium whitespace-nowrap`,children:[`统计数量`,(0,m.jsx)(l,{...G.resizeProps(4)})]}),(0,m.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,m.jsxs)(`tbody`,{children:[q.length===0?(0,m.jsx)(`tr`,{className:`border-t border-stone-100`,children:(0,m.jsx)(`td`,{colSpan:6,className:`px-4 py-14 text-center text-sm text-stone-400`,children:`还没有测试统计记录,点右上角「+ 添加记录」开始。`})}):null,Z.map((e,t)=>(0,m.jsxs)(`tr`,{className:`group/row border-t border-stone-100 ${e.id===R?`tw-new-row`:`hover:bg-[#f7f8fa]`}`,children:[(0,m.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,m.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.date} ${e.dimensions.join(`/`)}`,checked:!!M[e.id],onChange:t=>N(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,m.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:(X-1)*I+t+1}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(ne,{value:e.date,onChange:t=>void $(e.id,{date:t}),placeholder:`选择日期`,className:`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(ae,{compact:!0,ariaLabel:`测试统计维度`,options:w,value:e.dimensions[0]??``,onChange:t=>void $(e.id,{dimensions:t?[t]:[]}),placeholder:`选择或创建维度`})}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(me,{value:e.count,ariaLabel:`统计数量`,onCommit:t=>void $(e.id,{count:t})})}),(0,m.jsx)(`td`,{className:`px-1 py-1 text-center align-middle`,children:(0,m.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>V([e]),"aria-label":`删除 ${e.date} 的记录`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:x})})]},e.id))]})]})}),q.length>0?(0,m.jsx)(ie,{page:X,totalPages:Y,pageSize:I,busy:O,onPage:F,onPageSize:e=>{L(e),F(1)}}):(0,m.jsx)(`div`,{className:`pb-1`}),(0,m.jsx)(c,{open:B!==null,title:`删除测试统计`,message:B&&B.length>1?`确定删除选中的 ${B.length} 条记录吗?删除后不可恢复。`:`确定删除 ${B?.[0]?.date??``} 的这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>V(null),onConfirm:()=>void ve()})]}):(0,m.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`测试统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,m.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`testStats`)}):(0,m.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,m.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{S as default};
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DKMxjv3g.js";import{a as r,o as i,r as a}from"./plugins.D5ypJIXn.js";import{o,r as ee}from"./view-prefs.HCowOWXL.js";import{t as s}from"./jsx-runtime.BUXbF_vF.js";import{t as c}from"./ConfirmDialog.CBVsDJ8f.js";import{n as te,t as l}from"./ColumnResize.Bs6GL3DJ.js";import{t as ne}from"./DatePicker.CMfX7F6z.js";import{n as re,t as ie}from"./DocsPager.rzu4mnzw.js";import{t as ae}from"./TagSelect.u8DTop7v.js";import{a as oe,c as u,i as d,l as f,n as se,o as ce,r as le,s as ue,t as de,u as fe}from"./test-stats.MEm3K2rB.js";var p=e(t(),1),m=s(),h=8e3,g=600,_=20,pe=`tw.test-stats.page-size.v1`,v=`test-stats.search`,y=[{key:`select`,width:32,min:28},{key:`index`,width:44,min:36},{key:`date`,width:140,min:120},{key:`dimensions`,min:240},{key:`count`,width:120,min:90},{key:`action`,width:64,min:56}],b=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,x=(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,m.jsx)(`path`,{d:`M3 6h18`}),(0,m.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,m.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,m.jsx)(`path`,{d:`M10 11v6M14 11v6`})]});function me(e){let[t,n]=(0,p.useState)(e.value?String(e.value):``),r=(0,p.useRef)(e.value),i=(0,p.useRef)(e.onCommit);i.current=e.onCommit,(0,p.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,p.useEffect)(()=>{let e=t?u(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},g);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?u(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,m.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:b})}function S(){let[e,t]=(0,p.useState)(!1),[s,u]=(0,p.useState)(!0),[g,b]=(0,p.useState)(null),[S,C]=(0,p.useState)([]),[w,T]=(0,p.useState)([]),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(!1),[A,j]=(0,p.useState)(()=>ee(v)),[M,N]=(0,p.useState)({}),[P,F]=(0,p.useState)(1),[I,L]=re(_,pe),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(null);function H(e){o(v,e),j(e),F(1)}let U=(0,p.useRef)(!0),W=(0,p.useRef)(!1),G=te(`lh:test-stats:cols:v1`,y);(0,p.useEffect)(()=>(U.current=!0,()=>{U.current=!1}),[]);let K=(0,p.useCallback)(async()=>{try{let e=await oe();if(!U.current)return;C(e.items),T(e.dimensions),N(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),D(null)}catch(e){if(!U.current)return;D(e instanceof Error?e.message:String(e))}},[]);(0,p.useEffect)(()=>{let e=r(e=>u(!!e.testStats));return n().then(()=>{u(a(`testStats`)),t(!0)}),e},[]),(0,p.useEffect)(()=>{e&&s&&(async()=>{let e=await le();U.current&&(e?(await K(),U.current&&b(!0)):b(!1))})()},[e,s,K]),(0,p.useEffect)(()=>{if(g!==!0)return;let e=window.setInterval(()=>{W.current||K()},h),t=()=>{W.current||K()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[g,K]);let he=f(),q=(0,p.useMemo)(()=>ce(d(S,{keyword:A})),[S,A]),J=(0,p.useMemo)(()=>ue(S),[S]),Y=Math.max(1,Math.ceil(q.length/I)),X=Math.min(P,Y),Z=(0,p.useMemo)(()=>q.slice((X-1)*I,X*I),[q,X,I]),Q=(0,p.useMemo)(()=>S.filter(e=>M[e.id]),[S,M]),ge=Z.length>0&&Z.every(e=>M[e.id]);(0,p.useEffect)(()=>{if(!R)return;let e=q.findIndex(e=>e.id===R);if(e<0)return;F(Math.floor(e/I)+1);let t=window.setTimeout(()=>z(null),2e3);return()=>window.clearTimeout(t)},[R,q,I]);async function _e(){if(!O){k(!0),D(null),H(``);try{let e=await de([{date:he,dimensions:[],count:0}],{mode:`manual`});if(!U.current)return;let t=e.items[0];if(e.dimensions.length&&T(e.dimensions),await K(),!U.current||!t)return;z(t.id)}catch(e){U.current&&D(e instanceof Error?e.message:String(e))}finally{U.current&&k(!1)}}}async function $(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,dimensions:r}=await fe(e,t);if(!U.current)return;C(t=>t.map(t=>t.id===e?n:t)),r.length&&T(r),D(null)}catch(e){if(!U.current)return;D(e instanceof Error?e.message:String(e)),await K()}}async function ve(){let e=B;if(e&&e.length!==0){V(null),k(!0);try{if(await se(e.map(e=>e.id)),!U.current)return;N({}),D(null),await K()}catch(e){U.current&&D(e instanceof Error?e.message:String(e))}finally{U.current&&k(!1)}}}return e?s?g===null?(0,m.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接测试统计服务`,children:(0,m.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):g?(0,m.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,m.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,m.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,m.jsx)(`span`,{className:`font-medium text-stone-800`,children:J.records}),` 条`,(0,m.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 覆盖 `,J.dimensions,` 个维度 · 数量合计 `,J.total,Q.length?` · 已选 ${Q.length} 条`:``]})]}),(0,m.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,m.jsx)(`input`,{value:A,onChange:e=>H(e.target.value),placeholder:`搜索日期 / 维度…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,m.jsx)(`button`,{type:`button`,disabled:O||Q.length===0,onClick:()=>V(Q),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,m.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>void _e(),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 添加记录`})]})]}),E?(0,m.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,m.jsx)(`span`,{className:`min-w-0 flex-1`,children:E}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>D(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,m.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{W.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{W.current=!!document.activeElement?.closest(`.tw-data-table`)},0)},children:(0,m.jsxs)(`table`,{className:`tw-data-table w-full table-fixed border-collapse text-sm`,style:G.tableStyle,children:[(0,m.jsx)(`colgroup`,{children:y.map(e=>(0,m.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,m.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,m.jsxs)(`tr`,{children:[(0,m.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,children:(0,m.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:ge,disabled:Z.length===0,onChange:e=>{let t=e.target.checked;N(e=>{let n={...e};for(let e of Z)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,m.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,"aria-label":`行号`}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`当前日期`,(0,m.jsx)(l,{...G.resizeProps(2)})]}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`测试统计维度`,(0,m.jsx)(l,{...G.resizeProps(3)})]}),(0,m.jsxs)(`th`,{className:`relative px-2 py-2 text-center font-medium whitespace-nowrap`,children:[`统计数量`,(0,m.jsx)(l,{...G.resizeProps(4)})]}),(0,m.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),(0,m.jsxs)(`tbody`,{children:[q.length===0?(0,m.jsx)(`tr`,{className:`border-t border-stone-100`,children:(0,m.jsx)(`td`,{colSpan:6,className:`px-4 py-14 text-center text-sm text-stone-400`,children:`还没有测试统计记录,点右上角「+ 添加记录」开始。`})}):null,Z.map((e,t)=>(0,m.jsxs)(`tr`,{className:`group/row border-t border-stone-100 ${e.id===R?`tw-new-row`:`hover:bg-[#f7f8fa]`}`,children:[(0,m.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,m.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.date} ${e.dimensions.join(`/`)}`,checked:!!M[e.id],onChange:t=>N(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,m.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:(X-1)*I+t+1}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(ne,{value:e.date,onChange:t=>void $(e.id,{date:t}),placeholder:`选择日期`,className:`h-8 w-full rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(ae,{compact:!0,ariaLabel:`测试统计维度`,options:w,value:e.dimensions[0]??``,onChange:t=>void $(e.id,{dimensions:t?[t]:[]}),placeholder:`选择或创建维度`})}),(0,m.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,m.jsx)(me,{value:e.count,ariaLabel:`统计数量`,onCommit:t=>void $(e.id,{count:t})})}),(0,m.jsx)(`td`,{className:`px-1 py-1 text-center align-middle`,children:(0,m.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>V([e]),"aria-label":`删除 ${e.date} 的记录`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:x})})]},e.id))]})]})}),q.length>0?(0,m.jsx)(ie,{page:X,totalPages:Y,pageSize:I,busy:O,onPage:F,onPageSize:e=>{L(e),F(1)}}):(0,m.jsx)(`div`,{className:`pb-1`}),(0,m.jsx)(c,{open:B!==null,title:`删除测试统计`,message:B&&B.length>1?`确定删除选中的 ${B.length} 条记录吗?删除后不可恢复。`:`确定删除 ${B?.[0]?.date??``} 的这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>V(null),onConfirm:()=>void ve()})]}):(0,m.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`测试统计需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,m.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`testStats`)}):(0,m.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,m.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,m.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{S as default};
@@ -1 +1 @@
1
- import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.huKxSIlN.js";import{a as r,o as i,r as a}from"./plugins.DaDJq-mn.js";import{a as o,n as s,o as c,r as ee}from"./view-prefs.Dhdh8Z5a.js";import{i as l,n as te,r as u,t as ne}from"./dialog.DXHznyjD.js";import{t as d}from"./jsx-runtime.BUXbF_vF.js";import{t as f}from"./ConfirmDialog.CBVsDJ8f.js";import{n as p,t as m}from"./ColumnResize.Bs6GL3DJ.js";import{n as re,t as h}from"./DatePicker.CMfX7F6z.js";import{t as g}from"./SelectDropdown.Buv7rQJ_.js";import{A as _,C as v,D as ie,E as ae,M as oe,N as se,P as y,S as b,T as ce,_ as x,b as S,g as le,j as ue,k as de,n as C,u as fe,v as w,w as pe,x as me,y as T}from"./tasks.otRBFydq.js";import{a as E,c as D,i as he,l as O,n as k,o as A,r as j,s as M,t as N}from"./DrawerField.CWMLhcPX.js";var P=e(t(),1),F=d(),ge=8e3,_e=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`action`,width:80,min:64}],ve=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],ye={in_progress:`bg-[#3370ff] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},be={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},I={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},xe={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},Se={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},L={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},Ce=[`status`,`priority`,`none`],we=`todos.group-by`,Te=[`in_progress`,`pending`,`done`,`overdue`,`cancelled`],Ee=T.map(e=>({value:e,label:S[e]})),De=[{value:``,label:`未设置`},...x.map(e=>({value:e,label:w[e]}))],Oe=Object.keys(L).map(e=>({value:e,label:L[e]})),ke=[{value:`all`,label:`全部紧急程度`},...x.map(e=>({value:e,label:w[e]}))],Ae=ke.map(e=>e.value),je=`todos.priority-filter`,Me=`todos.search`,Ne=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function Pe(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,F.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${Ne} ${r&&!t?`text-stone-300`:``}`})}function Fe(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,P.useState)(!1);return a?(0,F.jsx)(Pe,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,F.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:t||(0,F.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function Ie(e){return(0,F.jsx)(h,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function Le(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:s}=e,[c,ee]=(0,P.useState)({title:``}),[d,f]=(0,P.useState)(``),[p,m]=(0,P.useState)(!1),[v,ie]=(0,P.useState)(!0);(0,P.useEffect)(()=>{t&&(f(``),m(!1),ie(!0),ee(n?{title:n.title,status:n.status,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pending`,priority:``,startDate:_(),dueDate:_(),...r}))},[t,n,r]);let oe=[{value:``,label:`不关联`},...i.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===n?.taskId).map(e=>({value:e.id,label:e.title}))];function b(e){ee(t=>({...t,...e}))}let ce=ue({startDate:c.startDate??``,dueDate:c.dueDate??``}),x=se({dueDate:c.dueDate??``}),le=ae(c.status??`pending`),de=le?re((n&&ae(n.status)?n.taskEndDate:``)||_()):``,fe=x===null?``:c.status===`done`?`已完成`:c.status===`cancelled`?`已取消`:x<0?`逾期 ${Math.abs(x)} 天`:x===0?`今天截止`:`${x} 天`;async function pe(){let e=(c.title??``).trim();if(!e)f(`请填写待办名称`);else if(c.startDate&&c.dueDate&&c.dueDate<c.startDate)f(`截止日期不能早于开始日期`);else{m(!0),f(``);try{let t={...c,title:e};n?await y(n.id,t):await me([t],{mode:`manual`}),await s(),o()}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(!1)}}}return(0,F.jsxs)(u,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,F.jsx)(ne,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,F.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,F.jsx)(te,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,F.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,F.jsx)(k,{icon:(0,F.jsx)(O,{}),label:`待办名称`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:c.title,onChange:e=>b({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),pe())},placeholder:`请输入内容`,className:N})}),(0,F.jsx)(k,{icon:(0,F.jsx)(M,{}),label:`待办状态`,children:(0,F.jsx)(j,{ariaLabel:`待办状态`,menuMinWidth:140,options:Ee,value:c.status??`pending`,onChange:e=>b({status:e}),label:S[c.status??`pending`],optionDotClassName:e=>xe[e]})}),(0,F.jsxs)(`button`,{type:`button`,onClick:()=>ie(e=>!e),"aria-expanded":v,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,F.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,F.jsx)(D,{})}),(0,F.jsx)(`span`,{children:`任务详情`}),(0,F.jsx)(`span`,{className:`text-stone-400`,children:(0,F.jsx)(he,{open:v})})]}),v?(0,F.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,F.jsx)(k,{icon:(0,F.jsx)(D,{}),label:`所属任务`,children:a?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{flat:!0,ariaLabel:`所属任务`,menuMinWidth:220,options:oe,value:c.taskId??``,onChange:e=>{let t=i.find(t=>t.id===e);b({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate ${c.taskId||c.linkedTask?`text-stone-800`:`text-stone-400`}`,children:c.taskId?i.find(e=>e.id===c.taskId)?.title??``:c.linkedTask||`请选择任务`})}),i.length===0?(0,F.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,F.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,F.jsx)(`span`,{className:`truncate`,children:c.linkedTask?`${c.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,F.jsx)(k,{icon:(0,F.jsx)(M,{}),label:`重要紧急程度`,children:(()=>{let e=c.taskId?i.find(e=>e.id===c.taskId):void 0;return e?(0,F.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,F.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?C[e.priority]:`任务未设置`}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,F.jsx)(j,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:De,value:c.priority??``,onChange:e=>b({priority:e}),label:c.priority?w[c.priority]:`未设置`,optionDotClassName:e=>Se[e]})})()}),(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`结束日期`,children:(0,F.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[de?(0,F.jsx)(`span`,{className:`text-stone-800`,children:de}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,F.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:le?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`开始日期`,children:(0,F.jsx)(h,{value:c.startDate??``,onChange:e=>b({startDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`截止日期`,children:(0,F.jsx)(h,{value:c.dueDate??``,onChange:e=>b({dueDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(A,{}),label:`待办周期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ce===null?`—`:`${ce} 天`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(A,{}),label:`剩余天数`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:fe||`—`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(O,{}),label:`备注`,children:(0,F.jsx)(`textarea`,{value:c.note??``,onChange:e=>b({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),d?(0,F.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:d}):null]}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:o,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>void pe(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function R(){let[e,t]=(0,P.useState)(!1),[l,te]=(0,P.useState)(!0),[u,ne]=(0,P.useState)(null),[d,C]=(0,P.useState)([]),[T,E]=(0,P.useState)([]),[D,he]=(0,P.useState)(!1),[O,k]=(0,P.useState)(null),[A,j]=(0,P.useState)(!1),[M,N]=(0,P.useState)(()=>ee(Me)),[L,Ne]=(0,P.useState)(()=>s(je,Ae,`all`)),[R,Re]=(0,P.useState)(()=>s(we,Ce,`status`)),[ze,Be]=(0,P.useState)({}),[z,Ve]=(0,P.useState)({});function He(e){o(we,e),Re(e)}function Ue(e){o(je,e),Ne(e)}function We(e){c(Me,e),N(e)}let[Ge,Ke]=(0,P.useState)({}),[B,V]=(0,P.useState)(null),[H,U]=(0,P.useState)(null),[qe,Je]=(0,P.useState)(!1),[Ye,Xe]=(0,P.useState)(null),W=(0,P.useRef)(!0),Ze=(0,P.useRef)(!1),Qe=(0,P.useRef)(!1),G=p(`lh:todos:cols:v1`,_e),$e=B!==null,K=(0,P.useRef)(B);K.current=B;let et=(0,P.useRef)(!1),tt=(0,P.useRef)(async()=>{});tt.current=ct,(0,P.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]),(0,P.useEffect)(()=>{if(!$e)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=K.current;if(!n)return;if(n.title.trim()){tt.current();return}let r=_();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&V(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[$e]);let q=(0,P.useCallback)(async()=>{try{let[e,t]=await Promise.all([ie(),D?fe().catch(()=>[]):Promise.resolve([])]);if(!W.current)return;let n=t;if(!Ze.current&&D){Ze.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>le(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}C(e),E(n),k(null)}catch(e){if(!W.current)return;k(e instanceof Error?e.message:String(e))}},[D]);(0,P.useEffect)(()=>{let e=r(e=>{te(!!e.todos),he(!!e.tasks)});return n().then(()=>{te(a(`todos`)),he(a(`tasks`)),t(!0)}),e},[]),(0,P.useEffect)(()=>{e&&l&&(async()=>{let e=await pe();W.current&&(e?(await q(),W.current&&ne(!0)):ne(!1))})()},[e,l,q]),(0,P.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{Qe.current||q()},ge),t=()=>{Qe.current||q()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,q]),(0,P.useEffect)(()=>{if(!D||u!==!0||T.length===0)return;let e=d.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=T.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await y(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&C(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[D,u,d,T]);function nt(e,t,n){Ke(r=>({...r,[e]:{...r[e],[t]:n}}))}function J(e){Ke(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let rt=(0,P.useMemo)(()=>[{value:``,label:`不关联`},...T.filter(e=>e.status!==`closed`&&e.status!==`cancelled`).map(e=>({value:e.id,label:e.title}))],[T]);function Y(e){return e.taskId?T.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function it(e){return e.taskId?T.find(t=>t.id===e.taskId):void 0}function at(e){let t=it(e);return t?t.priority:e.priority}async function X(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await y(e,t);if(!W.current)return;C(t=>t.map(t=>t.id===e?n:t)),k(null),t.taskId&&await q()}catch(e){k(e instanceof Error?e.message:String(e)),await q()}}async function ot(e){let t=Ge[e],n=d.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of ve){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)J(e);else if(typeof r.title==`string`&&!r.title.trim())k(`待办名称不能为空`),J(e);else try{let t=await y(e,r);if(!W.current)return;C(n=>n.map(n=>n.id===e?t:n)),Ke(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),k(null)}catch(t){k(t instanceof Error?t.message:String(t)),J(e)}}function st(e){let t=e.newStatus??`pending`,n=e.newPriority??``;V({groupKey:e.key,title:``,status:t,priority:n,taskId:``,startDate:_(),dueDate:_(),note:``,baseStatus:t,basePriority:n}),Be(t=>({...t,[e.key]:!1}))}async function ct(){let e=K.current;if(!e||et.current)return;let t=e.title.trim();if(t){et.current=!0,Je(!0);try{let n=T.find(t=>t.id===e.taskId);await me([{title:t,status:e.status,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),K.current===e&&V(null),k(null),await q()}catch(e){k(e instanceof Error?e.message:String(e))}finally{et.current=!1,W.current&&Je(!1)}}}async function lt(){let e=H;if(e){U(null),j(!0),k(null);try{await b(e.map(e=>e.id)),Ve({}),await q()}catch(e){k(e instanceof Error?e.message:String(e))}finally{W.current&&j(!1)}}}let Z=_(),ut=(0,P.useMemo)(()=>d.map(e=>{let t=e.taskId?T.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[d,T]),dt=(0,P.useMemo)(()=>ce(ut,{status:`all`,priority:L,keyword:M,today:Z}),[ut,L,M,Z]),Q=(0,P.useMemo)(()=>de(dt),[dt]),ft=(0,P.useMemo)(()=>R===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:R===`priority`?[...x,``].map(e=>({key:`priority:${e||`none`}`,label:e?w[e]:`未设置`,pill:e?I[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):Te.map(e=>({key:`status:${e}`,label:S[e],pill:ye[e],items:Q.filter(t=>v(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[R,Q,Z]).filter(e=>e.items.length>0||B?.groupKey===e.key&&!!B),pt=Object.keys(z).filter(e=>z[e]),$=(0,P.useMemo)(()=>{let e={total:d.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of d){let n=v(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[d,Z]);return e?l?u===null?(0,F.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接待办服务`,children:(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,F.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,F.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,F.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`input`,{value:M,onChange:e=>We(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,F.jsx)(g,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Oe,value:R,onChange:e=>He(e)}),(0,F.jsx)(g,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:ke,value:L,onChange:e=>Ue(e)}),(0,F.jsx)(`button`,{type:`button`,disabled:A||pt.length===0,onClick:()=>U(d.filter(e=>z[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,F.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>Xe({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建待办`})]})]}),O?(0,F.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,F.jsx)(`span`,{className:`min-w-0 flex-1`,children:O}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>k(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,F.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{Qe.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{Qe.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,F.jsxs)(`table`,{className:`tw-todo-table w-full table-fixed border-collapse text-sm`,style:G.tableStyle,children:[(0,F.jsx)(`colgroup`,{children:_e.map(e=>(0,F.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,F.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>z[e.id]),onChange:e=>{let t=e.target.checked;Ve(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,F.jsx)(`th`,{className:`px-1 py-2 text-left font-medium`,"aria-label":`行号`}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办名称`,(0,F.jsx)(m,{...G.resizeProps(2)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,F.jsx)(m,{...G.resizeProps(3)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,F.jsx)(m,{...G.resizeProps(4)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,F.jsx)(m,{...G.resizeProps(5)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,F.jsx)(m,{...G.resizeProps(6)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,F.jsx)(m,{...G.resizeProps(7)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,F.jsx)(m,{...G.resizeProps(8)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,F.jsx)(m,{...G.resizeProps(9)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,F.jsx)(m,{...G.resizeProps(10)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,F.jsx)(m,{...G.resizeProps(11)})]}),(0,F.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),ft.map(e=>{let t=ze[e.key]===!0;return(0,F.jsxs)(`tbody`,{children:[(0,F.jsx)(`tr`,{className:`border-t border-stone-100 bg-white`,children:(0,F.jsx)(`td`,{colSpan:13,className:`px-2 py-0 pt-3 pb-1.5`,children:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>Be(n=>({...n,[e.key]:!t})),className:`flex items-center gap-2 rounded-md px-1 py-0.5 text-left hover:bg-stone-50`,"aria-expanded":!t,children:[(0,F.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform ${t?`-rotate-90`:``}`,children:(0,F.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),(0,F.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),(0,F.jsxs)(`span`,{className:`text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})})}),t?null:e.items.map((e,t)=>{let n=Ge[e.id]??{},r={...e,...n},i=v(r,Z),a=ue(r),o=se(r,Z),s=o===null?`—`:r.status===`done`?`已完成`:r.status===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,F.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!z[e.id],onChange:t=>Ve(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:t+1}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,F.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,F.jsx)(Pe,{value:r.title,placeholder:`输入待办名称`,onChange:t=>nt(e.id,`title`,t),onCommit:()=>void ot(e.id),onCancel:()=>J(e.id)})]})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ee,value:e.status,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${be[i]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:S[i]}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${xe[e.value]}`})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:D?(0,F.jsx)(g,{unstyled:!0,ariaLabel:`所属任务`,menuMinWidth:220,options:rt,value:r.taskId,onChange:t=>{let n=T.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate ${Y(r)?`text-stone-800`:`text-stone-300`}`,children:Y(r)||`未关联`})}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:Y(r)?`${Y(r)} · 插件未启用`:`任务管理插件未启用`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:it(r)?(0,F.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${I[at(r)]??`text-stone-300`}`,children:at(r)?w[at(r)]:`未设置`}):(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:De,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${I[e.priority]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?w[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Se[e.value]}`})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Ie,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Ie,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:oe(r)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:re(oe(r))}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Fe,{value:r.note,onChange:t=>nt(e.id,`note`,t),onCommit:()=>void ot(e.id),onCancel:()=>J(e.id)})}),(0,F.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>Xe({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,F.jsx)(`path`,{d:`M14 4h6v6`}),(0,F.jsx)(`path`,{d:`M20 4 13 11`}),(0,F.jsx)(`path`,{d:`M10 20H4v-6`}),(0,F.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,F.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>U([e]),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,F.jsx)(`path`,{d:`M3 6h18`}),(0,F.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,F.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,F.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:B?.groupKey===e.key?(0,F.jsxs)(`tr`,{className:`tw-new-row border-t border-stone-100`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:B.title,disabled:qe,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>V(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ct()):e.key===`Escape`&&(e.preventDefault(),V(null))},className:`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff]`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ee,value:B.status,onChange:e=>V(t=>t&&{...t,status:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${be[B.status]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:S[B.status]})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:D?(0,F.jsx)(g,{unstyled:!0,ariaLabel:`所属任务`,menuMinWidth:220,options:rt,value:B.taskId,onChange:e=>V(t=>{if(!t)return t;let n=T.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=T.find(e=>e.id===B.taskId);return(0,F.jsx)(`span`,{className:`truncate ${e?`text-stone-800`:`text-stone-300`}`,children:e?.title||`未关联`})}}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=T.find(e=>e.id===B.taskId);return e?(0,F.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${I[e.priority]??`text-stone-300`}`,children:e.priority?w[e.priority]:`未设置`}):(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:De,value:B.priority,onChange:e=>V(t=>t&&{...t,priority:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${I[B.priority]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:B.priority?w[B.priority]:`未设置`})})})()}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(h,{value:B.startDate,onChange:e=>V(t=>t&&{...t,startDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(h,{value:B.dueDate,onChange:e=>V(t=>t&&{...t,dueDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:ae(B.status)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:re(_())}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(`input`,{value:B.note,disabled:qe,placeholder:`—`,onChange:e=>V(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,F.jsxs)(`tr`,{className:`border-t border-stone-100`,children:[(0,F.jsx)(`td`,{className:`px-2 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:11,children:(0,F.jsxs)(`button`,{type:`button`,disabled:qe,onClick:()=>st(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,F.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),ft.length===0?(0,F.jsx)(`tbody`,{children:(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:13,className:`px-3 py-16 text-center text-sm text-stone-400`,children:d.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,F.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,pt.length?` · 已选 ${pt.length}`:``]}),(0,F.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,F.jsx)(Le,{open:Ye!==null,item:Ye?.item??null,preset:Ye?.preset,tasks:T,tasksOn:D,onClose:()=>Xe(null),onSaved:q}),(0,F.jsx)(f,{open:H!=null,title:H&&H.length>1?`批量删除`:`删除待办`,message:H&&H.length>1?`确认删除已选中的 ${H.length} 条待办?此操作不可恢复。`:`删除「${H?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>U(null),onConfirm:()=>void lt()})]}):(0,F.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`待办事项需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,F.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`todos`)}):(0,F.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{R as default};
1
+ import{c as e,n as t}from"./react-dom.CqAxpHMt.js";import{i as n}from"./app-config.DKMxjv3g.js";import{a as r,o as i,r as a}from"./plugins.D5ypJIXn.js";import{a as o,n as s,o as c,r as ee}from"./view-prefs.HCowOWXL.js";import{i as l,n as te,r as u,t as ne}from"./dialog.DXHznyjD.js";import{t as d}from"./jsx-runtime.BUXbF_vF.js";import{t as f}from"./ConfirmDialog.CBVsDJ8f.js";import{n as p,t as m}from"./ColumnResize.Bs6GL3DJ.js";import{n as re,t as h}from"./DatePicker.CMfX7F6z.js";import{t as g}from"./SelectDropdown.Buv7rQJ_.js";import{A as _,C as v,D as ie,E as ae,M as oe,N as se,P as y,S as b,T as ce,_ as x,b as S,g as le,j as ue,k as de,n as C,u as fe,v as w,w as pe,x as me,y as T}from"./tasks.otRBFydq.js";import{a as E,c as D,i as he,l as O,n as k,o as A,r as j,s as M,t as N}from"./DrawerField.CWMLhcPX.js";var P=e(t(),1),F=d(),ge=8e3,_e=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`action`,width:80,min:64}],ve=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],ye={in_progress:`bg-[#3370ff] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},be={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},I={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},xe={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},Se={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},L={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},Ce=[`status`,`priority`,`none`],we=`todos.group-by`,Te=[`in_progress`,`pending`,`done`,`overdue`,`cancelled`],Ee=T.map(e=>({value:e,label:S[e]})),De=[{value:``,label:`未设置`},...x.map(e=>({value:e,label:w[e]}))],Oe=Object.keys(L).map(e=>({value:e,label:L[e]})),ke=[{value:`all`,label:`全部紧急程度`},...x.map(e=>({value:e,label:w[e]}))],Ae=ke.map(e=>e.value),je=`todos.priority-filter`,Me=`todos.search`,Ne=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function Pe(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,F.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${Ne} ${r&&!t?`text-stone-300`:``}`})}function Fe(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,P.useState)(!1);return a?(0,F.jsx)(Pe,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,F.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:t||(0,F.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function Ie(e){return(0,F.jsx)(h,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function Le(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:s}=e,[c,ee]=(0,P.useState)({title:``}),[d,f]=(0,P.useState)(``),[p,m]=(0,P.useState)(!1),[v,ie]=(0,P.useState)(!0);(0,P.useEffect)(()=>{t&&(f(``),m(!1),ie(!0),ee(n?{title:n.title,status:n.status,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pending`,priority:``,startDate:_(),dueDate:_(),...r}))},[t,n,r]);let oe=[{value:``,label:`不关联`},...i.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===n?.taskId).map(e=>({value:e.id,label:e.title}))];function b(e){ee(t=>({...t,...e}))}let ce=ue({startDate:c.startDate??``,dueDate:c.dueDate??``}),x=se({dueDate:c.dueDate??``}),le=ae(c.status??`pending`),de=le?re((n&&ae(n.status)?n.taskEndDate:``)||_()):``,fe=x===null?``:c.status===`done`?`已完成`:c.status===`cancelled`?`已取消`:x<0?`逾期 ${Math.abs(x)} 天`:x===0?`今天截止`:`${x} 天`;async function pe(){let e=(c.title??``).trim();if(!e)f(`请填写待办名称`);else if(c.startDate&&c.dueDate&&c.dueDate<c.startDate)f(`截止日期不能早于开始日期`);else{m(!0),f(``);try{let t={...c,title:e};n?await y(n.id,t):await me([t],{mode:`manual`}),await s(),o()}catch(e){f(e instanceof Error?e.message:String(e))}finally{m(!1)}}}return(0,F.jsxs)(u,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,F.jsx)(ne,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,F.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,F.jsx)(te,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,F.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,F.jsx)(k,{icon:(0,F.jsx)(O,{}),label:`待办名称`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:c.title,onChange:e=>b({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),pe())},placeholder:`请输入内容`,className:N})}),(0,F.jsx)(k,{icon:(0,F.jsx)(M,{}),label:`待办状态`,children:(0,F.jsx)(j,{ariaLabel:`待办状态`,menuMinWidth:140,options:Ee,value:c.status??`pending`,onChange:e=>b({status:e}),label:S[c.status??`pending`],optionDotClassName:e=>xe[e]})}),(0,F.jsxs)(`button`,{type:`button`,onClick:()=>ie(e=>!e),"aria-expanded":v,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,F.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,F.jsx)(D,{})}),(0,F.jsx)(`span`,{children:`任务详情`}),(0,F.jsx)(`span`,{className:`text-stone-400`,children:(0,F.jsx)(he,{open:v})})]}),v?(0,F.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,F.jsx)(k,{icon:(0,F.jsx)(D,{}),label:`所属任务`,children:a?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{flat:!0,ariaLabel:`所属任务`,menuMinWidth:220,options:oe,value:c.taskId??``,onChange:e=>{let t=i.find(t=>t.id===e);b({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate ${c.taskId||c.linkedTask?`text-stone-800`:`text-stone-400`}`,children:c.taskId?i.find(e=>e.id===c.taskId)?.title??``:c.linkedTask||`请选择任务`})}),i.length===0?(0,F.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,F.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,F.jsx)(`span`,{className:`truncate`,children:c.linkedTask?`${c.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,F.jsx)(k,{icon:(0,F.jsx)(M,{}),label:`重要紧急程度`,children:(()=>{let e=c.taskId?i.find(e=>e.id===c.taskId):void 0;return e?(0,F.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,F.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?C[e.priority]:`任务未设置`}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,F.jsx)(j,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:De,value:c.priority??``,onChange:e=>b({priority:e}),label:c.priority?w[c.priority]:`未设置`,optionDotClassName:e=>Se[e]})})()}),(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`结束日期`,children:(0,F.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[de?(0,F.jsx)(`span`,{className:`text-stone-800`,children:de}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,F.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:le?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`开始日期`,children:(0,F.jsx)(h,{value:c.startDate??``,onChange:e=>b({startDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(E,{}),label:`截止日期`,children:(0,F.jsx)(h,{value:c.dueDate??``,onChange:e=>b({dueDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(A,{}),label:`待办周期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ce===null?`—`:`${ce} 天`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(A,{}),label:`剩余天数`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:fe||`—`})}),(0,F.jsx)(k,{icon:(0,F.jsx)(O,{}),label:`备注`,children:(0,F.jsx)(`textarea`,{value:c.note??``,onChange:e=>b({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),d?(0,F.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:d}):null]}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:o,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>void pe(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function R(){let[e,t]=(0,P.useState)(!1),[l,te]=(0,P.useState)(!0),[u,ne]=(0,P.useState)(null),[d,C]=(0,P.useState)([]),[T,E]=(0,P.useState)([]),[D,he]=(0,P.useState)(!1),[O,k]=(0,P.useState)(null),[A,j]=(0,P.useState)(!1),[M,N]=(0,P.useState)(()=>ee(Me)),[L,Ne]=(0,P.useState)(()=>s(je,Ae,`all`)),[R,Re]=(0,P.useState)(()=>s(we,Ce,`status`)),[ze,Be]=(0,P.useState)({}),[z,Ve]=(0,P.useState)({});function He(e){o(we,e),Re(e)}function Ue(e){o(je,e),Ne(e)}function We(e){c(Me,e),N(e)}let[Ge,Ke]=(0,P.useState)({}),[B,V]=(0,P.useState)(null),[H,U]=(0,P.useState)(null),[qe,Je]=(0,P.useState)(!1),[Ye,Xe]=(0,P.useState)(null),W=(0,P.useRef)(!0),Ze=(0,P.useRef)(!1),Qe=(0,P.useRef)(!1),G=p(`lh:todos:cols:v1`,_e),$e=B!==null,K=(0,P.useRef)(B);K.current=B;let et=(0,P.useRef)(!1),tt=(0,P.useRef)(async()=>{});tt.current=ct,(0,P.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]),(0,P.useEffect)(()=>{if(!$e)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=K.current;if(!n)return;if(n.title.trim()){tt.current();return}let r=_();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&V(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[$e]);let q=(0,P.useCallback)(async()=>{try{let[e,t]=await Promise.all([ie(),D?fe().catch(()=>[]):Promise.resolve([])]);if(!W.current)return;let n=t;if(!Ze.current&&D){Ze.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>le(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}C(e),E(n),k(null)}catch(e){if(!W.current)return;k(e instanceof Error?e.message:String(e))}},[D]);(0,P.useEffect)(()=>{let e=r(e=>{te(!!e.todos),he(!!e.tasks)});return n().then(()=>{te(a(`todos`)),he(a(`tasks`)),t(!0)}),e},[]),(0,P.useEffect)(()=>{e&&l&&(async()=>{let e=await pe();W.current&&(e?(await q(),W.current&&ne(!0)):ne(!1))})()},[e,l,q]),(0,P.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{Qe.current||q()},ge),t=()=>{Qe.current||q()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,q]),(0,P.useEffect)(()=>{if(!D||u!==!0||T.length===0)return;let e=d.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=T.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await y(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&C(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[D,u,d,T]);function nt(e,t,n){Ke(r=>({...r,[e]:{...r[e],[t]:n}}))}function J(e){Ke(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let rt=(0,P.useMemo)(()=>[{value:``,label:`不关联`},...T.filter(e=>e.status!==`closed`&&e.status!==`cancelled`).map(e=>({value:e.id,label:e.title}))],[T]);function Y(e){return e.taskId?T.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function it(e){return e.taskId?T.find(t=>t.id===e.taskId):void 0}function at(e){let t=it(e);return t?t.priority:e.priority}async function X(e,t){C(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await y(e,t);if(!W.current)return;C(t=>t.map(t=>t.id===e?n:t)),k(null),t.taskId&&await q()}catch(e){k(e instanceof Error?e.message:String(e)),await q()}}async function ot(e){let t=Ge[e],n=d.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of ve){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)J(e);else if(typeof r.title==`string`&&!r.title.trim())k(`待办名称不能为空`),J(e);else try{let t=await y(e,r);if(!W.current)return;C(n=>n.map(n=>n.id===e?t:n)),Ke(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),k(null)}catch(t){k(t instanceof Error?t.message:String(t)),J(e)}}function st(e){let t=e.newStatus??`pending`,n=e.newPriority??``;V({groupKey:e.key,title:``,status:t,priority:n,taskId:``,startDate:_(),dueDate:_(),note:``,baseStatus:t,basePriority:n}),Be(t=>({...t,[e.key]:!1}))}async function ct(){let e=K.current;if(!e||et.current)return;let t=e.title.trim();if(t){et.current=!0,Je(!0);try{let n=T.find(t=>t.id===e.taskId);await me([{title:t,status:e.status,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),K.current===e&&V(null),k(null),await q()}catch(e){k(e instanceof Error?e.message:String(e))}finally{et.current=!1,W.current&&Je(!1)}}}async function lt(){let e=H;if(e){U(null),j(!0),k(null);try{await b(e.map(e=>e.id)),Ve({}),await q()}catch(e){k(e instanceof Error?e.message:String(e))}finally{W.current&&j(!1)}}}let Z=_(),ut=(0,P.useMemo)(()=>d.map(e=>{let t=e.taskId?T.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[d,T]),dt=(0,P.useMemo)(()=>ce(ut,{status:`all`,priority:L,keyword:M,today:Z}),[ut,L,M,Z]),Q=(0,P.useMemo)(()=>de(dt),[dt]),ft=(0,P.useMemo)(()=>R===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:R===`priority`?[...x,``].map(e=>({key:`priority:${e||`none`}`,label:e?w[e]:`未设置`,pill:e?I[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):Te.map(e=>({key:`status:${e}`,label:S[e],pill:ye[e],items:Q.filter(t=>v(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[R,Q,Z]).filter(e=>e.items.length>0||B?.groupKey===e.key&&!!B),pt=Object.keys(z).filter(e=>z[e]),$=(0,P.useMemo)(()=>{let e={total:d.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of d){let n=v(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[d,Z]);return e?l?u===null?(0,F.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接待办服务`,children:(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,F.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,F.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,F.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`input`,{value:M,onChange:e=>We(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,F.jsx)(g,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Oe,value:R,onChange:e=>He(e)}),(0,F.jsx)(g,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:ke,value:L,onChange:e=>Ue(e)}),(0,F.jsx)(`button`,{type:`button`,disabled:A||pt.length===0,onClick:()=>U(d.filter(e=>z[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,F.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>Xe({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建待办`})]})]}),O?(0,F.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,F.jsx)(`span`,{className:`min-w-0 flex-1`,children:O}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>k(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,F.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{Qe.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{Qe.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,F.jsxs)(`table`,{className:`tw-todo-table w-full table-fixed border-collapse text-sm`,style:G.tableStyle,children:[(0,F.jsx)(`colgroup`,{children:_e.map(e=>(0,F.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,F.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:`px-2 py-2 text-left font-medium`,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>z[e.id]),onChange:e=>{let t=e.target.checked;Ve(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,F.jsx)(`th`,{className:`px-1 py-2 text-left font-medium`,"aria-label":`行号`}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办名称`,(0,F.jsx)(m,{...G.resizeProps(2)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,F.jsx)(m,{...G.resizeProps(3)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,F.jsx)(m,{...G.resizeProps(4)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,F.jsx)(m,{...G.resizeProps(5)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,F.jsx)(m,{...G.resizeProps(6)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,F.jsx)(m,{...G.resizeProps(7)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,F.jsx)(m,{...G.resizeProps(8)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,F.jsx)(m,{...G.resizeProps(9)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,F.jsx)(m,{...G.resizeProps(10)})]}),(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,F.jsx)(m,{...G.resizeProps(11)})]}),(0,F.jsx)(`th`,{className:`px-1 py-2 text-center font-medium whitespace-nowrap`,children:`操作`})]})}),ft.map(e=>{let t=ze[e.key]===!0;return(0,F.jsxs)(`tbody`,{children:[(0,F.jsx)(`tr`,{className:`border-t border-stone-100 bg-white`,children:(0,F.jsx)(`td`,{colSpan:13,className:`px-2 py-0 pt-3 pb-1.5`,children:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>Be(n=>({...n,[e.key]:!t})),className:`flex items-center gap-2 rounded-md px-1 py-0.5 text-left hover:bg-stone-50`,"aria-expanded":!t,children:[(0,F.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform ${t?`-rotate-90`:``}`,children:(0,F.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),(0,F.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),(0,F.jsxs)(`span`,{className:`text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})})}),t?null:e.items.map((e,t)=>{let n=Ge[e.id]??{},r={...e,...n},i=v(r,Z),a=ue(r),o=se(r,Z),s=o===null?`—`:r.status===`done`?`已完成`:r.status===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,F.jsxs)(`tr`,{className:`group/row border-t border-stone-100 hover:bg-[#f7f8fa]`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!z[e.id],onChange:t=>Ve(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:t+1}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,F.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,F.jsx)(Pe,{value:r.title,placeholder:`输入待办名称`,onChange:t=>nt(e.id,`title`,t),onCommit:()=>void ot(e.id),onCancel:()=>J(e.id)})]})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ee,value:e.status,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${be[i]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:S[i]}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${xe[e.value]}`})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:D?(0,F.jsx)(g,{unstyled:!0,ariaLabel:`所属任务`,menuMinWidth:220,options:rt,value:r.taskId,onChange:t=>{let n=T.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate ${Y(r)?`text-stone-800`:`text-stone-300`}`,children:Y(r)||`未关联`})}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:Y(r)?`${Y(r)} · 插件未启用`:`任务管理插件未启用`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:it(r)?(0,F.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${I[at(r)]??`text-stone-300`}`,children:at(r)?w[at(r)]:`未设置`}):(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:De,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${I[e.priority]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?w[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Se[e.value]}`})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Ie,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Ie,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:oe(r)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:re(oe(r))}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(Fe,{value:r.note,onChange:t=>nt(e.id,`note`,t),onCommit:()=>void ot(e.id),onCancel:()=>J(e.id)})}),(0,F.jsx)(`td`,{className:`px-1 py-1 text-right align-middle`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>Xe({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,F.jsx)(`path`,{d:`M14 4h6v6`}),(0,F.jsx)(`path`,{d:`M20 4 13 11`}),(0,F.jsx)(`path`,{d:`M10 20H4v-6`}),(0,F.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,F.jsx)(`button`,{type:`button`,disabled:A,onClick:()=>U([e]),"aria-label":`删除 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-red-50 hover:text-red-600 focus:text-red-600 disabled:opacity-40`,children:(0,F.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,F.jsx)(`path`,{d:`M3 6h18`}),(0,F.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,F.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,F.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:B?.groupKey===e.key?(0,F.jsxs)(`tr`,{className:`tw-new-row border-t border-stone-100`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:B.title,disabled:qe,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>V(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ct()):e.key===`Escape`&&(e.preventDefault(),V(null))},className:`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff]`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ee,value:B.status,onChange:e=>V(t=>t&&{...t,status:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${be[B.status]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:S[B.status]})})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:D?(0,F.jsx)(g,{unstyled:!0,ariaLabel:`所属任务`,menuMinWidth:220,options:rt,value:B.taskId,onChange:e=>V(t=>{if(!t)return t;let n=T.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=T.find(e=>e.id===B.taskId);return(0,F.jsx)(`span`,{className:`truncate ${e?`text-stone-800`:`text-stone-300`}`,children:e?.title||`未关联`})}}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}),(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=T.find(e=>e.id===B.taskId);return e?(0,F.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${I[e.priority]??`text-stone-300`}`,children:e.priority?w[e.priority]:`未设置`}):(0,F.jsx)(g,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:De,value:B.priority,onChange:e=>V(t=>t&&{...t,priority:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${I[B.priority]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`w-full truncate text-center`,children:B.priority?w[B.priority]:`未设置`})})})()}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(h,{value:B.startDate,onChange:e=>V(t=>t&&{...t,startDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(h,{value:B.dueDate,onChange:e=>V(t=>t&&{...t,dueDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:ae(B.status)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:re(_())}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(`input`,{value:B.note,disabled:qe,placeholder:`—`,onChange:e=>V(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,F.jsxs)(`tr`,{className:`border-t border-stone-100`,children:[(0,F.jsx)(`td`,{className:`px-2 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:11,children:(0,F.jsxs)(`button`,{type:`button`,disabled:qe,onClick:()=>st(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,F.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),ft.length===0?(0,F.jsx)(`tbody`,{children:(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:13,className:`px-3 py-16 text-center text-sm text-stone-400`,children:d.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,F.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,pt.length?` · 已选 ${pt.length}`:``]}),(0,F.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,F.jsx)(Le,{open:Ye!==null,item:Ye?.item??null,preset:Ye?.preset,tasks:T,tasksOn:D,onClose:()=>Xe(null),onSaved:q}),(0,F.jsx)(f,{open:H!=null,title:H&&H.length>1?`批量删除`:`删除待办`,message:H&&H.length>1?`确认删除已选中的 ${H.length} 条待办?此操作不可恢复。`:`删除「${H?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>U(null),onConfirm:()=>void lt()})]}):(0,F.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`待办事项需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,F.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:i(`todos`)}):(0,F.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{R as default};
@@ -0,0 +1 @@
1
+ var e=[{id:`functional`,label:`功能测试`,casesFolder:`功能测试`,templateFolder:`功能测试用例`},{id:`api`,label:`接口测试`,casesFolder:`接口测试`,templateFolder:`接口测试用例`},{id:`performance`,label:`性能测试`,casesFolder:`性能测试`,templateFolder:`性能测试用例`},{id:`automation`,label:`自动化测试`,casesFolder:`自动化测试`,templateFolder:`自动化测试用例`}];function t(){return`ct_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function n(e){let t=e.trim()||`未命名类型`;return{casesFolder:t,templateFolder:`${t}用例`}}function r(e){if(!e||typeof e!=`object`)return null;let r=e,i=String(r.label??``).trim();if(!i)return null;let a=String(r.id??``).trim()||t(),o=n(i);return{id:a,label:i,casesFolder:typeof r.casesFolder==`string`&&r.casesFolder.trim()?r.casesFolder.trim():o.casesFolder,templateFolder:typeof r.templateFolder==`string`&&r.templateFolder.trim()?r.templateFolder.trim():o.templateFolder}}function i(t){if(!Array.isArray(t))return e.map(e=>({...e}));let n=[],i=new Set;for(let e of t){let t=r(e);t&&!i.has(t.id)&&(i.add(t.id),n.push(t))}return n.length?n:e.map(e=>({...e}))}function a(){return t()}var o=[`测试规范`,`方法论`,`环境约定`];function s(e){if(!Array.isArray(e))return[...o];let t=[],n=new Set;for(let r of e){let e=String(r??``).trim();!e||e.length>40||n.has(e)||(n.add(e),t.push(e))}return t.length?t:[...o]}var c=[{id:`case`,label:`用例生成提示词`,hint:`用于编写「用例生成」提示词:指导模型按需求与模板输出可入库用例;须约束 JSON 结构、字段对齐模板、步骤换行与覆盖策略,不要限定固定用例条数。`},{id:`general`,label:`通用提示词`,hint:`用于编写通用测试/工作台提示词:角色、输出风格与约束清晰,可直接作为系统或任务提示词使用。`}];function l(){return`pk_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function u(e){return`生成「${e.trim()||`自定义`}」类提示词:角色、输出风格与约束清晰,可直接作为系统或任务提示词使用。`}function d(e){if(!e||typeof e!=`object`)return null;let t=e,n=String(t.label??``).trim();if(!n)return null;let r=String(t.id??``).trim()||l(),i=typeof t.hint==`string`&&t.hint.trim()?t.hint.trim():u(n);return r===`case`&&i.includes(`「测试用例生成」`)&&(i=c[0].hint),{id:r,label:n,hint:i}}function f(e){if(!Array.isArray(e))return c.map(e=>({...e}));let t=[],n=new Set;for(let r of e){let e=d(r);e&&!n.has(e.id)&&(n.add(e.id),t.push(e))}return t.length?t:c.map(e=>({...e}))}function ee(){return l()}var p=[{id:`dashboard`,href:`dashboard/`,i18n:`nav.dashboard`,plugin:`dashboard`,match:`dashboard`},{id:`tasks`,href:`tasks/`,i18n:`nav.tasks`,plugin:`tasks`,match:`tasks`},{id:`todos`,href:`todos/`,i18n:`nav.todos`,plugin:`todos`,match:`todos`},{id:`projects`,href:`pm/projects/`,i18n:`nav.projects`,plugin:`projects`,match:`pm/projects`},{id:`iterations`,href:`pm/iterations/`,i18n:`nav.iterations`,plugin:`iterations`,match:`pm/iterations`},{id:`pmRequirements`,href:`pm/requirements/`,i18n:`nav.requirementsMgmt`,plugin:`pmRequirements`,match:`pm/requirements`},{id:`bugs`,href:`pm/bugs/`,i18n:`nav.bugs`,plugin:`bugs`,match:`pm/bugs`},{id:`reports`,href:`reports/`,i18n:`nav.reports`,plugin:`reports`,match:`reports`},{id:`testStats`,href:`test-stats/`,i18n:`nav.testStats`,plugin:`testStats`,match:`test-stats`},{id:`caseExec`,href:`case-exec/`,i18n:`nav.caseExec`,plugin:`caseExec`,match:`case-exec`},{id:`cases`,href:`cases/library/`,i18n:`nav.caseManage`,plugin:`cases`,match:`cases`},{id:`prompts`,href:`prompts/`,i18n:`nav.prompts`,plugin:`prompts`,match:`prompts`},{id:`knowledgeLib`,href:`knowledge/`,i18n:`nav.knowledge`,plugin:`knowledgeLib`,match:`knowledge`},{id:`requirements`,href:`requirements/`,i18n:`nav.requirements`,plugin:`requirements`,match:`requirements`},{id:`templates`,href:`templates/`,i18n:`nav.templates`,plugin:`templates`,match:`templates`}],m=[],te=[`prompts`];function h(e){return te.includes(e)}var g=[`check`,`pencil`,`book`,`fileText`,`layers`,`list`,`folder`,`star`,`database`,`target`,`code`,`flask`,`home`,`clipboard`,`bug`,`calendar`,`chart`,`globe`,`link`,`users`,`terminal`,`tag`,`flag`,`zap`,`dashboard`],_={dashboard:`dashboard`,tasks:`clipboard`,todos:`list`,projects:`folder`,iterations:`calendar`,pmRequirements:`fileText`,bugs:`bug`,reports:`fileText`,testStats:`chart`,caseExec:`target`,cases:`check`,prompts:`pencil`,knowledgeLib:`book`,requirements:`fileText`,templates:`layers`};function ne(e){return typeof e==`string`&&g.includes(e)}function v(e){let t={..._};if(!e||typeof e!=`object`||Array.isArray(e))return t;for(let n of p){let r=e[n.id];ne(r)&&(t[n.id]=r)}return t}var y=new Set(p.map(e=>e.id));function b(e){return typeof e==`string`&&y.has(e)}function re(e){return p.find(t=>t.id===e)}function ie(e,t=`/`){let n=t.replace(/\/$/,``),r=(n&&e.startsWith(n)?e.slice(n.length):e).replace(/^\/+/,``);return r?p.filter(e=>r===e.match||r.startsWith(`${e.match}/`)).sort((e,t)=>t.match.length-e.match.length)[0]??null:null}function x(e){return`item:${e}`}function S(e){return`group:${e}`}function C(){return`ng_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function w(){return m.map(e=>({id:e.id,name:e.name,items:[...e.items]}))}function T(e,t=!0){if(e==null||!Array.isArray(e))return t?w():[];let n=new Set,r=[],i=new Set;for(let t of e){if(!t||typeof t!=`object`)continue;let e=t,a=String(e.name??``).trim();if(!a)continue;let o=String(e.id??``).trim()||C();i.has(o)&&(o=C());let s=[];if(Array.isArray(e.items))for(let t of e.items)b(t)&&!n.has(t)&&(n.add(t),s.push(t));let c=String(e.parentId??``).trim()||void 0;i.add(o),r.push({id:o,name:a,items:s,parentId:c})}let a=new Set(r.map(e=>e.id)),o=r.map(e=>{let t=e.parentId;return(!t||t===e.id||!a.has(t))&&(t=void 0),t?{...e,parentId:t}:{id:e.id,name:e.name,items:e.items}}),s=new Map(o.map(e=>[e.id,e])),c=o.map(e=>{if(!e.parentId)return e;let t=s.get(e.parentId);if(t?.parentId){let n=t.parentId;return n&&n!==e.id&&a.has(n)?{...e,parentId:n}:{id:e.id,name:e.name,items:e.items}}return e}),l=new Set(c.map(e=>e.parentId).filter(e=>!!e));return c.filter(e=>e.items.length>0||l.has(e.id))}function E(e,t){let n=t.name.trim(),r=t.items.filter((e,t,n)=>b(e)&&n.indexOf(e)===t);if(!n||!r.length)return{groups:e,id:t.id?.trim()||``};let i=t.id?.trim()||C(),a=e.find(e=>e.id===i),o=t.parentId===void 0?a?.parentId:t.parentId.trim()||void 0;if(o===i&&(o=void 0),o){let t=e.find(e=>e.id===o);t?t.parentId&&(o=t.parentId):o=void 0}let s=new Set(r),c=e.filter(e=>e.id!==i).map(e=>({...e,items:e.items.filter(e=>!s.has(e))}));return c.push(o?{id:i,name:n,items:r,parentId:o}:{id:i,name:n,items:r}),{groups:T(c),id:i}}function ae(e,t){return e.filter(e=>e.parentId===t).map(e=>e.id)}function D(e,t){return e.filter(e=>e.parentId===t)}function oe(e,t){let n=e.find(e=>e.id===t);if(!n)return e;let r=e.filter(e=>e.id!==t);return n.parentId?r.map(e=>e.id===n.parentId?{...e,items:[...e.items,...n.items]}:e.parentId===t?{...e,parentId:n.parentId}:e):r.map(e=>e.parentId===t?{id:e.id,name:e.name,items:e.items}:e)}function se(e,t,n){let r=e.find(e=>e.id===t);return!r||!b(n)||r.items.includes(n)?e:E(e,{id:r.id,name:r.name,items:[...r.items,n]}).groups}function ce(e,t){let n=e.find(e=>e.items.includes(t))??null;return n?{groups:e.map(e=>e.id===n.id?{...e,items:e.items.filter(e=>e!==t)}:e).filter(e=>e.items.length>0),owner:n}:{groups:e,owner:null}}function le(e,t,n,r){let i=x(t),a=S(n.id),o=r.some(e=>e.id===n.id),s=e.indexOf(a),c=e.filter(e=>e!==i&&(o||e!==a)),l=s<0?c.length:o?s+1:s;return c.splice(l,0,i),k(c,r)}function ue(e){let t=new Map(e.map(e=>[e.id,e])),n=new Map;for(let r of e){let e=r.parentId?t.get(r.parentId)??r:r;for(let t of r.items)n.set(t,e)}let r=new Set,i=[];for(let e of p){let t=n.get(e.id);if(t){if(r.has(t.id))continue;r.add(t.id),i.push({type:`group`,group:t})}else i.push({type:`item`,id:e.id})}return i}function O(e){let t=new Map;for(let n of e){if(!n.parentId)continue;let e=t.get(n.parentId);e?e.push(n):t.set(n.parentId,[n])}let n=[],r=new Set,i=e=>{if(!r.has(e.id)){r.add(e.id),n.push(S(e.id));for(let n of t.get(e.id)??[])i(n)}};for(let t of ue(e))t.type===`item`?n.push(x(t.id)):i(t.group);for(let t of e)i(t);return n}function de(e){let t=new Set,n=new Set;for(let r of e){n.add(S(r.id));for(let e of r.items)t.add(e)}for(let e of p)t.has(e.id)||n.add(x(e.id));return n}function k(e,t){let n=de(t),r=[],i=new Set;if(Array.isArray(e))for(let t of e)typeof t==`string`&&n.has(t)&&!i.has(t)&&(i.add(t),r.push(t));for(let e of O(t))i.has(e)||r.push(e);return r}function fe(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Set(e.flatMap(e=>e.items)),i=k(t,e),a=[];for(let e of i)if(e.startsWith(`group:`)){let t=n.get(e.slice(6));t&&!t.parentId&&a.push({type:`group`,group:t})}else if(e.startsWith(`item:`)){let t=e.slice(5);b(t)&&!r.has(t)&&a.push({type:`item`,id:t})}return a}function pe(e,t,n){let r=t.find(e=>e.id===n);if(!r)return k(e,t);let i=new Set(r.items.map(e=>x(e))),a=S(n);if(r.parentId){let n=e.filter(e=>e!==a),i=S(r.parentId),o=n.indexOf(i),s=[...n];return o<0?s.push(a):s.splice(o+1,0,a),k(s,t)}let o=[...e],s=o.length;for(let e=0;e<o.length;e++){let t=o[e];if(t===a||i.has(t)){s=o.slice(0,e).filter(e=>e!==a&&!i.has(e)).length;break}}let c=o.filter(e=>e!==a&&!i.has(e));return c.splice(s,0,a),k(c,t)}function me(e,t,n){let r=D(e,t);if(!n?.length||r.length<2)return r;let i=new Map;return n.forEach((e,t)=>{i.has(e)||i.set(e,t)}),r.map((e,t)=>({group:e,i:t,at:i.get(S(e.id))})).sort((e,t)=>{let n=e.at??1/0,r=t.at??1/0;return n===r?e.i-t.i:n-r}).map(e=>e.group)}function he(e,t,n,r){let i=new Map(t.map(e=>[e.id,e])),a=r.filter(e=>i.get(e)?.parentId===n),o=new Set(a.map(S)),s=e.filter(e=>!o.has(e)),c=S(n),l=s.indexOf(c),u=a.map(S),d=[...s];return l<0?d.push(...u):d.splice(l+1,0,...u),k(d,t)}function ge(e,t){if(!e.startsWith(`group:`))return!1;let n=e.slice(6);return t.some(e=>e.id===n&&!!e.parentId)}function _e(e,t,n,r=[]){if(t.parentId)return k(e,n);let i=S(t.id),a=[...r.map(e=>S(e)),...t.items.map(e=>x(e))],o=e.filter(e=>e!==i);return o.push(...a),k(o,n)}function ve(e,t,n){let r=e.indexOf(t),i=e.indexOf(n);if(r<0||i<0||r===i)return[...e];let a=[...e],[o]=a.splice(r,1);return o===void 0?[...e]:(a.splice(i,0,o),a)}var A=`tw.space.active-id`,ye=`tw.spaces.list.v1`;function j(e,t){try{return(e===`local`?localStorage:sessionStorage).getItem(t)?.trim()||``}catch{return``}}function M(e,t,n){try{(e===`local`?localStorage:sessionStorage).setItem(t,n)}catch{}}function N(e){let t=String(e||``).trim();t&&(M(`session`,A,t),M(`local`,A,t))}function P(){let e=j(`session`,A);if(e)return e;let t=j(`local`,A);if(t)return t;try{let e=sessionStorage.getItem(ye);if(!e)return``;let t=JSON.parse(e);return String(t?.activeId||``).trim()}catch{return``}}function F(e){let t=P();return t?`${e}::${t}`:e}var I=`/__tb_config`,L=`tw.app.config.v1`,R=`tw.app.apikey.v1`,z=`tw.app.model.v1`,B=!1,V=null,H=``,U=!1,be={language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``};function W(){return`p_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function xe(e){if(!e||typeof e!=`object`)return null;let t=String(e.name??``).trim()||`未命名提供商`,n=String(e.baseURL??``).trim(),r=String(e.model??``).trim();return{id:String(e.id??``).trim()||W(),name:t,baseURL:n,model:r,apiKey:typeof e.apiKey==`string`&&e.apiKey.trim()?e.apiKey.trim():void 0,availableModels:Array.isArray(e.availableModels)?e.availableModels.filter(e=>typeof e==`string`):void 0}}function Se(e){let t=typeof e.baseURL==`string`?e.baseURL.trim():``,n=typeof e.model==`string`?e.model.trim():``;return!t&&!n&&!e.apiKey?[]:[{id:W(),name:`默认`,baseURL:t||`https://api.deepseek.com/v1`,model:n,apiKey:typeof e.apiKey==`string`&&e.apiKey.trim()?e.apiKey.trim():void 0,availableModels:Array.isArray(e.availableModels)?e.availableModels.filter(e=>typeof e==`string`):void 0}]}function G(e){let t=e?.reasoningEffort===`low`||e?.reasoningEffort===`high`||e?.reasoningEffort===`max`?e.reasoningEffort:`high`,n=[];Array.isArray(e?.providers)&&e.providers.length?n=e.providers.map(e=>xe(e)).filter(e=>!!e):e&&(e.baseURL||e.model||e.apiKey)&&(n=Se(e));let r=typeof e?.activeId==`string`?e.activeId:``;return n.length&&!n.some(e=>e.id===r)&&(r=n[0].id),n.length||(r=``),{activeId:r,reasoningEffort:t,providers:n}}function K(){return{version:1,model:{activeId:``,reasoningEffort:`high`,providers:[]},access:`readonly`,general:{...be},plugins:{cases:!1,caseGen:!1,prompts:!0,promptGen:!1,knowledgeLib:!1,knowledgeGen:!1,requirements:!1,templates:!1,knowledge:!1,memory:!1,pluginDev:!1,todos:!1,tasks:!1,projects:!1,iterations:!1,pmRequirements:!1,bugs:!1,reports:!1,testStats:!1,caseExec:!1,dashboard:!1},caseTypes:e.map(e=>({...e})),promptKinds:c.map(e=>({...e})),knowledgeCategories:[...o],navGroups:m.map(e=>({...e,items:[...e.items]})),navIcons:{..._},navOrder:O(m)}}function q(e){let t=K();if(!e||typeof e!=`object`)return t;let n=e.general&&typeof e.general==`object`?e.general:{},r={...t.plugins,...e.plugins??{}},a=T(e.navGroups);return{version:typeof e.version==`number`?e.version:1,model:G(e.model),access:e.access===`readwrite`||e.access===`full`||e.access===`readonly`?e.access:`readonly`,general:{language:n.language===`en`?`en`:`zh-CN`,appearance:n.appearance===`light`||n.appearance===`dark`||n.appearance===`system`?n.appearance:`system`,sessionFontSize:typeof n.sessionFontSize==`number`&&n.sessionFontSize>=12&&n.sessionFontSize<=22?Math.round(n.sessionFontSize):14,toolStepDetail:n.toolStepDetail===`concise`||n.toolStepDetail===`standard`||n.toolStepDetail===`detailed`||n.toolStepDetail===`full`?n.toolStepDetail:`standard`,busySendBehavior:n.busySendBehavior===`interrupt`?`interrupt`:`queue`,subagentModel:typeof n.subagentModel==`string`?n.subagentModel.trim():``},plugins:r,caseTypes:i(e.caseTypes),promptKinds:f(e.promptKinds),knowledgeCategories:s(e.knowledgeCategories),navGroups:a,navIcons:v(e.navIcons),navOrder:k(e.navOrder,a)}}function Ce(){try{let e=localStorage.getItem(z);if(e)return G(JSON.parse(e))}catch{}try{let e=localStorage.getItem(F(L));if(e){let t=JSON.parse(e);if(t?.model)return G(t.model)}}catch{}return null}function we(e){try{localStorage.setItem(z,JSON.stringify(e))}catch{}}function J(){try{let e=localStorage.getItem(F(L)),t=Ce();if(!e)return t?q({...K(),model:t}):null;let n=q(JSON.parse(e));return t&&(n.model=t),n}catch{return null}}function Y(e){try{let{model:t,...n}=e;localStorage.setItem(F(L),JSON.stringify(n)),we(t)}catch{}}function Te(){try{return localStorage.getItem(R)?.trim()||localStorage.getItem(F(R))?.trim()||``}catch{return``}}function Ee(e){try{e?localStorage.setItem(R,e):localStorage.removeItem(R),localStorage.removeItem(F(R))}catch{}}function De(){try{let e=K(),t=!1,n=localStorage.getItem(`tw-llm-settings`);if(n){let r=JSON.parse(n);e.model=G({providers:[{id:W(),name:r.name||`默认`,baseURL:r.baseURL||``,model:r.model||``,apiKey:r.apiKey,availableModels:r.availableModels}],reasoningEffort:r.reasoningEffort}),e.model.providers[0]&&(e.model.activeId=e.model.providers[0].id),t=!0}let r=localStorage.getItem(`tw-access-level`);(r===`readonly`||r===`readwrite`||r===`full`)&&(e.access=r,t=!0);let i=localStorage.getItem(`tw.general.prefs.v1`);i&&(e.general=q({general:JSON.parse(i)}).general,t=!0);let a=localStorage.getItem(`tw.plugins.enabled.v1`);if(a){let n=JSON.parse(a);e.plugins={...e.plugins,...n},t=!0}return t?e:null}catch{return null}}function X(e){let t=e.model.providers;return t.length?t.find(t=>t.id===e.model.activeId)??t[0]??null:null}function Oe(){return B}function ke(){return V||Z(),V??K()}function Z(){if(!U&&(U=!0,typeof window<`u`))try{let e=J();e&&(V=e)}catch{}}function Ae(){return H}function je(){return[...V?.model.providers??[]]}async function Me(){try{let e=await fetch(I,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();V=q(t.config);let n=X(V),r=String(t.apiKey??``).trim();return H=r||n?.apiKey?.trim()||``,r&&n&&!n.apiKey&&(H=r),B=!0,Y(V),V}}catch{}B=!1;let e=J();return e||=De()??K(),V=e,H=X(e)?.apiKey?.trim()||Te(),Y(V),V}var Q=null;async function $(e){if(Y(e),B)try{await fetch(I,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({config:e})})}catch{}}function Ne(e){let t=V??K(),n=q({...t,...e,model:e.model?{...t.model,...e.model,providers:e.model.providers??t.model.providers}:t.model,general:{...t.general,...e.general??{}},plugins:{...t.plugins,...e.plugins??{}},caseTypes:e.caseTypes??t.caseTypes,promptKinds:e.promptKinds??t.promptKinds,knowledgeCategories:e.knowledgeCategories??t.knowledgeCategories,navGroups:e.navGroups??t.navGroups,navIcons:e.navIcons??t.navIcons,navOrder:e.navOrder??t.navOrder});return V=n,H=X(n)?.apiKey?.trim()||``,Q&&clearTimeout(Q),Q=setTimeout(()=>{Q=null,$(n)},280),n}function Pe(){return Q&&=(clearTimeout(Q),null),$(V??K())}function Fe(e){if(H=e.trim(),B||Ee(H),!V)return;let t=V.model.providers.map(e=>e.id===V.model.activeId?{...e,apiKey:H||void 0}:e);V=q({...V,model:{...V.model,providers:t}})}function Ie(){let e=V;if(!e)return null;let t=X(e);if(!t?.baseURL?.trim()||!t.model?.trim())return null;let n=(t.apiKey||H).trim();return n?{baseURL:t.baseURL.trim(),apiKey:n,model:t.model.trim(),reasoningEffort:e.model.reasoningEffort,availableModels:t.availableModels}:null}function Le(){return W()}export{he as A,u as B,h as C,T as D,ie as E,ce as F,e as G,f as H,oe as I,i as J,n as K,ve as L,_e as M,pe as N,v as O,me as P,E as R,ge as S,D as T,o as U,ee as V,s as W,se as _,Oe as a,re as b,Fe as c,P as d,N as f,g,p as h,Me as i,le as j,k,Ie as l,_ as m,Ae as n,je as o,F as p,a as q,ke as r,Le as s,Pe as t,Ne as u,fe as v,x as w,S as x,ae as y,c as z};