lantern-harness 0.1.35 → 0.1.36

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 (74) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/500.html +4 -4
  3. package/dist/_astro/Base.B-G3Zgu4.css +1 -0
  4. package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.CiZNg228.js → Base.astro_astro_type_script_index_0_lang.CvmRHkFv.js} +1 -1
  5. package/dist/_astro/CaseExecBoard.BWxBjYPI.js +1 -0
  6. package/dist/_astro/{CaseGenerateApp.BvRwwxhs.js → CaseGenerateApp.BxkQ-HTK.js} +1 -1
  7. package/dist/_astro/CasesLibrary.BU1q0MvV.js +24 -0
  8. package/dist/_astro/ChatApp.DXlSptIj.js +226 -0
  9. package/dist/_astro/{KnowledgeLibrary.CQ8ULHI5.js → KnowledgeLibrary.CiBRybeE.js} +1 -1
  10. package/dist/_astro/{LifeKrTasksBoard.BWoB442i.js → LifeKrTasksBoard.RENBU_z9.js} +1 -1
  11. package/dist/_astro/{LifeKrTodosBoard.rDbG9XcJ.js → LifeKrTodosBoard.CbNnGHSZ.js} +1 -1
  12. package/dist/_astro/{LifeObjectivesBoard.DUDQg_RD.js → LifeObjectivesBoard.BTGFpny2.js} +1 -1
  13. package/dist/_astro/{LifePlanTypeSelect.BtXnXOkz.js → LifePlanTypeSelect.BGtEEsL-.js} +1 -1
  14. package/dist/_astro/{LifeReviewsBoard.p-dp_NXl.js → LifeReviewsBoard.Bn-uxMI5.js} +1 -1
  15. package/dist/_astro/LifeShared.SnLIiFdN.js +3 -0
  16. package/dist/_astro/{LifeStagesBoard.BSvhzmp_.js → LifeStagesBoard.DrbIVrCK.js} +1 -1
  17. package/dist/_astro/{LifeYearCycleSelect.Q4VvLY8X.js → LifeYearCycleSelect.CuiWO8Tc.js} +1 -1
  18. package/dist/_astro/{LifeYearPlansBoard.CYN2gZKp.js → LifeYearPlansBoard.ChAoQUB5.js} +1 -1
  19. package/dist/_astro/{PluginsPage.DE3qbeY5.js → PluginsPage.Bxu1FEvU.js} +1 -1
  20. package/dist/_astro/PluginsPage.C_hLqPed.js +1 -0
  21. package/dist/_astro/{PromptsLibrary.Dp1S_lHQ.js → PromptsLibrary.D3huSjPf.js} +1 -1
  22. package/dist/_astro/ReportsPage.BU3GtBvl.js +1 -0
  23. package/dist/_astro/{ReqAnalysisBoard.B3bhMWmE.js → ReqAnalysisBoard.DGrYx1I5.js} +1 -1
  24. package/dist/_astro/{SettingsDialog.BzGBZlo2.js → SettingsDialog.C3qqpZPT.js} +1 -1
  25. package/dist/_astro/{TodosBoard.Bkuw_LDW.js → TodosBoard.ofiKHKcQ.js} +1 -1
  26. package/dist/_astro/app-version.BuvzE2YQ.js +1 -0
  27. package/dist/_astro/{case-exec.BLqTXR7U.js → case-exec.BMNk9OyF.js} +1 -1
  28. package/dist/_astro/{case-gen-run.CH0ldlsU.js → case-gen-run.BWQpCgpW.js} +1 -1
  29. package/dist/_astro/open-docs-in-session.5cTowYAC.js +1 -0
  30. package/dist/_astro/{report-prompt.CAfZ6RIo.js → report-prompt.B9C4cv84.js} +1 -1
  31. package/dist/_astro/{req-analysis.CjhgP3jI.js → req-analysis.BOz9djQo.js} +1 -1
  32. package/dist/_astro/{story-review.BBfB1qYF.js → story-review.Bvz3alFd.js} +1 -1
  33. package/dist/case-exec/index.html +5 -5
  34. package/dist/cases/generate/index.html +5 -5
  35. package/dist/cases/library/index.html +5 -5
  36. package/dist/dashboard/index.html +4 -4
  37. package/dist/docs/changelog/index.html +62 -41
  38. package/dist/docs/install/index.html +4 -4
  39. package/dist/docs/manual/index.html +9 -8
  40. package/dist/knowledge/index.html +5 -5
  41. package/dist/life/kr-tasks/index.html +5 -5
  42. package/dist/life/kr-todos/index.html +5 -5
  43. package/dist/life/objectives/index.html +5 -5
  44. package/dist/life/reviews/index.html +5 -5
  45. package/dist/life/stages/index.html +5 -5
  46. package/dist/life/year-plans/index.html +5 -5
  47. package/dist/plugins/index.html +5 -5
  48. package/dist/pm/bugs/index.html +4 -4
  49. package/dist/pm/iterations/index.html +4 -4
  50. package/dist/pm/projects/detail/index.html +4 -4
  51. package/dist/pm/projects/index.html +4 -4
  52. package/dist/pm/requirements/index.html +4 -4
  53. package/dist/prompts/index.html +5 -5
  54. package/dist/reports/index.html +5 -5
  55. package/dist/requirement-analysis/index.html +5 -5
  56. package/dist/requirements/index.html +4 -4
  57. package/dist/tasks/index.html +4 -4
  58. package/dist/templates/index.html +4 -4
  59. package/dist/test-automation/index.html +4 -4
  60. package/dist/test-stats/index.html +4 -4
  61. package/dist/todos/index.html +5 -5
  62. package/dist/workbench/index.html +5 -5
  63. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +5 -4
  64. package/lh-plugins/lh-reports.mjs +50 -0
  65. package/package.json +1 -1
  66. package/dist/_astro/Base.DjXU-4S_.css +0 -1
  67. package/dist/_astro/CaseExecBoard.DzNtPCwr.js +0 -1
  68. package/dist/_astro/CasesLibrary.B9I31b7C.js +0 -24
  69. package/dist/_astro/ChatApp.79JSgx7d.js +0 -226
  70. package/dist/_astro/LifeShared.Di9sdb_T.js +0 -3
  71. package/dist/_astro/PluginsPage.r98lZChB.js +0 -1
  72. package/dist/_astro/ReportsPage.C8uufWVb.js +0 -1
  73. package/dist/_astro/app-version.CXqYg1a3.js +0 -1
  74. package/dist/_astro/open-docs-in-session.BdihMTEh.js +0 -1
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i,s as a}from"./plugins.C0NrHGZv.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.D5qXeML0.js";import{showToast as c}from"./Toast.BO2NFckG.js";import{c as l,n as u,r as d,u as f}from"./project-docs.DAw9bzgk.js";import{n as p}from"./doc-roots.DAJP9Svr.js";import{i as m,n as h,r as g,t as _}from"./DocsFileBrowser.9WTBumS5.js";import{d as v,t as y}from"./open-docs-in-session.BdihMTEh.js";var b=e(t(),1),x=o(),S=10;async function C(e=`.`){let{entries:t}=await l(`knowledge`,e),n=[];for(let e of t)e.type===`file`?e.name.endsWith(`.md`)&&n.push(e):n.push(...await C(e.path));return n}function w({staticCount:e=0,base:t}){let o=g(`knowledge`),[l,w]=(0,b.useState)(!1),[T,E]=(0,b.useState)(!0),[D,O]=(0,b.useState)(o?!0:null),[k,A]=(0,b.useState)(()=>o??[]),[j,M]=(0,b.useState)(null),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)({}),[L,R]=(0,b.useState)(null),z=h(k,S,`knowledge`),B=(0,b.useCallback)(async()=>{M(null);try{let e=await C(`.`);A(e),m(`knowledge`,e)}catch(e){M(e instanceof Error?e.message:String(e))}},[]);(0,b.useEffect)(()=>{let e=i(e=>E(!!e.knowledgeLib));return n().then(()=>{E(r(`knowledgeLib`)),w(!0)}),e},[]),(0,b.useEffect)(()=>{l&&T&&(async()=>{await d(`knowledge`)?(await v().catch(()=>null),await B(),O(!0)):O(!1)})()},[l,T,B]);let V=(0,b.useMemo)(()=>Object.keys(F).filter(e=>F[e]),[F]);function H(){r(`knowledgeGen`)?window.location.href=`${t}workbench/?plugin=knowledgeGen`:M(a(`knowledgeGen`))}async function U(e){P(!0),M(null);try{await f(`knowledge`,e.path)}catch(e){M(e instanceof Error?e.message:String(e))}finally{P(!1)}}async function W(e){P(!0),M(null);try{await y(`knowledge`,e)}catch(e){M(e instanceof Error?e.message:String(e)),P(!1)}}async function G(){let e=L;if(e){R(null),P(!0),M(null);try{if(e.kind===`one`)await u(`knowledge`,e.entry.path);else{for(let t of e.paths)await u(`knowledge`,t);I({})}await B(),c(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个知识库文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),c(`删除失败:${t}`,`error`)}finally{P(!1)}}}let K=L?.kind===`one`?`删除「${L.entry.name}」?将从 ${p(`knowledge`)} 中移除。`:L?.kind===`batch`?`确认删除已选中的 ${L.paths.length} 个知识库文件?此操作不可恢复。`:``;return l?T?D===null?(0,x.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):D?(0,x.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,x.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[z.query.trim()?(0,x.jsxs)(x.Fragment,{children:[`匹配 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:z.filtered.length}),` 个`,(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,k.length]})]}):(0,x.jsxs)(x.Fragment,{children:[`共 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:k.length}),` 个知识库文件`]}),V.length>0?(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,V.length]}):null]}),(0,x.jsx)(`button`,{type:`button`,disabled:N||V.length===0,onClick:()=>R({kind:`batch`,paths:V}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,x.jsx)(`button`,{type:`button`,disabled:N,onClick:H,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:`生成知识库`})]}),j?(0,x.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:j}):null,(0,x.jsx)(_,{resizeKey:`docs:knowledge:cols:v1`,files:k,filtered:z.filtered,pageFiles:z.pageFiles,query:z.query,onQuery:z.setQuery,sortBy:z.sortBy,onSortBy:z.setSortBy,page:z.page,totalPages:z.totalPages,pageSize:z.pageSize,onPage:z.setPage,onPageSize:z.setPageSize,busy:N,emptyText:`暂无知识库文件,点击「生成知识库」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selected:F,onToggleRow:e=>I(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>I(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void U(e),renderBadge:e=>{let t=e.path.includes(`/`)?e.path.split(`/`)[0]:``;return t?(0,x.jsx)(`span`,{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded bg-amber-50 text-amber-800 border border-amber-100`,children:t}):null},renderActions:e=>(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>void W(e),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,x.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>R({kind:`one`,entry:e}),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40`,children:`删除`})]})}),(0,x.jsx)(s,{open:L!=null,title:L?.kind===`batch`?`批量删除`:`删除知识库文件`,message:K,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>R(null),onConfirm:()=>void G()})]}):(0,x.jsxs)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:[`知识库管理需要本地文档服务,当前未就绪`,e>0?`(构建期约有 ${e} 份文档可浏览)`:``,`。`]}):(0,x.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:a(`knowledgeLib`)}):(0,x.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{w as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i,s as a}from"./plugins.C0NrHGZv.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.D5qXeML0.js";import{showToast as c}from"./Toast.BO2NFckG.js";import{c as l,n as u,r as d,u as f}from"./project-docs.DAw9bzgk.js";import{n as p}from"./doc-roots.DAJP9Svr.js";import{i as m,n as h,r as g,t as _}from"./DocsFileBrowser.9WTBumS5.js";import{d as v,t as y}from"./open-docs-in-session.5cTowYAC.js";var b=e(t(),1),x=o(),S=10;async function C(e=`.`){let{entries:t}=await l(`knowledge`,e),n=[];for(let e of t)e.type===`file`?e.name.endsWith(`.md`)&&n.push(e):n.push(...await C(e.path));return n}function w({staticCount:e=0,base:t}){let o=g(`knowledge`),[l,w]=(0,b.useState)(!1),[T,E]=(0,b.useState)(!0),[D,O]=(0,b.useState)(o?!0:null),[k,A]=(0,b.useState)(()=>o??[]),[j,M]=(0,b.useState)(null),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)({}),[L,R]=(0,b.useState)(null),z=h(k,S,`knowledge`),B=(0,b.useCallback)(async()=>{M(null);try{let e=await C(`.`);A(e),m(`knowledge`,e)}catch(e){M(e instanceof Error?e.message:String(e))}},[]);(0,b.useEffect)(()=>{let e=i(e=>E(!!e.knowledgeLib));return n().then(()=>{E(r(`knowledgeLib`)),w(!0)}),e},[]),(0,b.useEffect)(()=>{l&&T&&(async()=>{await d(`knowledge`)?(await v().catch(()=>null),await B(),O(!0)):O(!1)})()},[l,T,B]);let V=(0,b.useMemo)(()=>Object.keys(F).filter(e=>F[e]),[F]);function H(){r(`knowledgeGen`)?window.location.href=`${t}workbench/?plugin=knowledgeGen`:M(a(`knowledgeGen`))}async function U(e){P(!0),M(null);try{await f(`knowledge`,e.path)}catch(e){M(e instanceof Error?e.message:String(e))}finally{P(!1)}}async function W(e){P(!0),M(null);try{await y(`knowledge`,e)}catch(e){M(e instanceof Error?e.message:String(e)),P(!1)}}async function G(){let e=L;if(e){R(null),P(!0),M(null);try{if(e.kind===`one`)await u(`knowledge`,e.entry.path);else{for(let t of e.paths)await u(`knowledge`,t);I({})}await B(),c(e.kind===`one`?`已删除「${e.entry.name}」`:`已删除 ${e.paths.length} 个知识库文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),c(`删除失败:${t}`,`error`)}finally{P(!1)}}}let K=L?.kind===`one`?`删除「${L.entry.name}」?将从 ${p(`knowledge`)} 中移除。`:L?.kind===`batch`?`确认删除已选中的 ${L.paths.length} 个知识库文件?此操作不可恢复。`:``;return l?T?D===null?(0,x.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):D?(0,x.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,x.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0`,children:[z.query.trim()?(0,x.jsxs)(x.Fragment,{children:[`匹配 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:z.filtered.length}),` 个`,(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 共 `,k.length]})]}):(0,x.jsxs)(x.Fragment,{children:[`共 `,(0,x.jsx)(`span`,{className:`font-medium text-stone-800`,children:k.length}),` 个知识库文件`]}),V.length>0?(0,x.jsxs)(`span`,{className:`text-stone-400`,children:[` · 已选 `,V.length]}):null]}),(0,x.jsx)(`button`,{type:`button`,disabled:N||V.length===0,onClick:()=>R({kind:`batch`,paths:V}),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-red-600 border border-red-200 rounded-lg hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,x.jsx)(`button`,{type:`button`,disabled:N,onClick:H,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:`生成知识库`})]}),j?(0,x.jsx)(`div`,{className:`shrink-0 mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:j}):null,(0,x.jsx)(_,{resizeKey:`docs:knowledge:cols:v1`,files:k,filtered:z.filtered,pageFiles:z.pageFiles,query:z.query,onQuery:z.setQuery,sortBy:z.sortBy,onSortBy:z.setSortBy,page:z.page,totalPages:z.totalPages,pageSize:z.pageSize,onPage:z.setPage,onPageSize:z.setPageSize,busy:N,emptyText:`暂无知识库文件,点击「生成知识库」前往我的工作台。`,searchPlaceholder:`搜索文件名或路径…`,selected:F,onToggleRow:e=>I(t=>({...t,[e]:!t[e]})),onSelectPage:(e,t)=>I(n=>{let r={...n};for(let n of e)t?r[n]=!0:delete r[n];return r}),onRowDoubleClick:e=>void U(e),renderBadge:e=>{let t=e.path.includes(`/`)?e.path.split(`/`)[0]:``;return t?(0,x.jsx)(`span`,{className:`shrink-0 text-[10px] px-1.5 py-0.5 rounded bg-amber-50 text-amber-800 border border-amber-100`,children:t}):null},renderActions:e=>(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>void W(e),className:`text-xs whitespace-nowrap text-white bg-[#4176e6] px-2 py-1 rounded hover:bg-[#3565c7] cursor-pointer disabled:opacity-40`,children:`在会话中打开`}),(0,x.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>R({kind:`one`,entry:e}),className:`text-xs whitespace-nowrap text-red-600 hover:bg-red-50 px-2 py-1 rounded cursor-pointer disabled:opacity-40`,children:`删除`})]})}),(0,x.jsx)(s,{open:L!=null,title:L?.kind===`batch`?`批量删除`:`删除知识库文件`,message:K,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>R(null),onConfirm:()=>void G()})]}):(0,x.jsxs)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:[`知识库管理需要本地文档服务,当前未就绪`,e>0?`(构建期约有 ${e} 份文档可浏览)`:``,`。`]}):(0,x.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:a(`knowledgeLib`)}):(0,x.jsx)(`div`,{className:`rounded-xl border border-stone-200 bg-white overflow-hidden flex flex-col min-h-0`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,x.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center`,children:(0,x.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{w as default};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.TgxIOKMD.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{c as s,d as c,i as l,l as u,n as d,o as f,t as p}from"./ColumnResize.CkE59sGq.js";import{$ as m,A as ee,B as h,C as g,D as _,E as te,H as v,I as ne,J as re,K as ie,L as ae,M as y,N as oe,Q as se,R as ce,S as le,T as ue,U as de,V as fe,W as b,X as pe,Y as me,Z as he,_ as ge,at as _e,b as x,c as ve,ct as ye,d as be,et as xe,f as S,g as Se,h as C,ht as Ce,j as we,k as Te,l as w,m as T,n as Ee,nt as E,o as D,ot as O,p as De,pt as Oe,q as ke,r as Ae,s as je,tt as k,u as Me,v as Ne,w as Pe,wt as Fe,x as Ie,xt as Le,y as Re,yt as ze,z as A}from"./LifeShared.Di9sdb_T.js";import{c as j,l as M,n as N,r as P,s as F,t as Be}from"./DrawerField.CiHAvXHQ.js";import{t as Ve}from"./LifePlanTypeSelect.BtXnXOkz.js";var I=e(t(),1),L=n(),He=[{key:`select`,width:36,min:32},{key:`title`,width:220,min:160},{key:`status`,width:104,min:76},{key:`priority`,width:104,min:84},{key:`planType`,width:112,min:88},{key:`objective`,width:160,min:100},{key:`year`,width:88,min:72},{key:`quarter`,width:120,min:88},{key:`todoList`,width:180,min:120},{key:`todos`,width:72,min:56},{key:`summary`,width:160,min:100},{key:`progress`,width:120,min:96},{key:`note`,width:120,min:88},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Ue=[{key:`status`,label:`状态`},{key:`priority`,label:`重要紧急程度`},{key:`planType`,label:`计划类型`},{key:`objective`,label:`所属目标`},{key:`year`,label:`年度周期`},{key:`quarter`,label:`季度周期`},{key:`todoList`,label:`待办列表`},{key:`todos`,label:`待办数`},{key:`summary`,label:`待办摘要`},{key:`progress`,label:`完成度`},{key:`note`,label:`备注`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],We=`life.kr-tasks.fields`,Ge=`life.kr-tasks.search`,Ke=`life.kr-tasks.group`,qe=`life.kr-tasks.status`,Je=[`yearStatus`,`yearPriority`,`yearPlanType`,`status`,`priority`,`none`],Ye=k.map(e=>({value:e,label:E[e]})),Xe=Ee,Ze=[`urgent_important`,`urgent`,`important`,`normal`,``],Qe=w,$e=_e.filter(e=>e!==``).map(e=>({value:e,label:O[e]})),et=[{value:`none`,label:`不分组`},{value:`yearStatus`,label:`按年度 → 状态`},{value:`yearPriority`,label:`按年度 → 重要紧急程度`},{value:`yearPlanType`,label:`按年度 → 计划类型`},{value:`status`,label:`按状态分组`},{value:`priority`,label:`按重要紧急程度分组`}],tt=[`all`,...k],nt=[{value:`all`,label:`全部状态`},...k.map(e=>({value:e,label:E[e]}))];function rt(e){return{title:``,status:e?.status??`pool`,priority:e?.priority??``,planType:e?.planType??``,objectiveId:e?.objectiveId??``,note:e?.note??``}}function it(e){let t={},n=/(?:^|\|)status:([^|]+)/.exec(e)?.[1];n&&k.includes(n)&&(t.status=n);let r=/(?:^|\|)priority:([^|]+)/.exec(e)?.[1];r===`unset`?t.priority=``:r&&Ze.includes(r)&&(t.priority=r);let i=/(?:^|\|)planType:([^|]+)/.exec(e)?.[1];return i===`unset`?t.planType=``:i&&(t.planType=i),t}function at(e){let{open:t,item:n,objectiveOptions:r,store:o,mutate:s,isVisible:c,onClose:l,onSave:u}=e,[d,f]=(0,I.useState)(rt()),[p,m]=(0,I.useState)(!1),[ee,h]=(0,I.useState)(``);(0,I.useEffect)(()=>{t&&(h(``),m(!1),f({title:n.title,status:n.status,priority:n.priority,planType:n.planType||``,objectiveId:n.objectiveId,note:n.note}))},[t,n,o.planTypes]);let g=b(o,d.objectiveId),_=Ce(n.id,o.krTodos);async function te(){let e=d.title.trim();if(!e)h(`请填写任务描述`);else{m(!0);try{await u({...d,title:e},n.id),l()}catch(e){h(e instanceof Error?e.message:String(e))}finally{m(!1)}}}return(0,L.jsxs)(x,{open:t,title:`任务详情`,onClose:l,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:l,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void te(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:`保存`})]}),children:[ee?(0,L.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:ee}):null,(0,L.jsx)(N,{icon:(0,L.jsx)(M,{}),label:`任务描述`,children:(0,L.jsx)(`input`,{autoFocus:!0,value:d.title,onChange:e=>f({...d,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),te())},placeholder:`请输入内容`,className:Be})}),c(`status`)?(0,L.jsx)(N,{icon:(0,L.jsx)(F,{}),label:`任务状态`,children:(0,L.jsx)(P,{ariaLabel:`任务状态`,options:Ye,value:d.status,onChange:e=>f({...d,status:e}),label:E[d.status],optionDotClassName:e=>Ae[e]})}):null,c(`priority`)?(0,L.jsx)(N,{icon:(0,L.jsx)(F,{}),label:`重要紧急程度`,children:(0,L.jsx)(P,{ariaLabel:`重要紧急程度`,options:$e,value:d.priority,onChange:e=>f({...d,priority:e}),label:d.priority?O[d.priority]:C,optionDotClassName:e=>Me[e]})}):null,c(`planType`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`任务类型`,children:(0,L.jsx)(Ve,{flat:!0,className:`w-full`,ariaLabel:`任务类型`,planTypes:o.planTypes,value:d.planType,onChange:e=>f({...d,planType:e}),mutate:s,renderTrigger:(e,{empty:t})=>(0,L.jsx)(i,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,c(`objective`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`所属目标`,children:(0,L.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`所属目标`,options:r,value:d.objectiveId,onChange:e=>f({...d,objectiveId:e}),className:`w-full`,triggerClassName:d.objectiveId?void 0:D,renderTrigger:()=>d.objectiveId&&g?(0,L.jsx)(i,{text:g.title,className:`block min-w-0 truncate text-stone-800`}):(0,L.jsx)(i,{text:T,className:`block min-w-0 truncate text-stone-400`})})}):null,c(`year`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`年度周期`,children:(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:g?.yearCycle?.trim()&&Fe(o.yearCycles,g.yearCycle)||`—`})}):null,c(`quarter`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`季度周期`,children:(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:g?.quarter?ye[g.quarter]:`—`})}):null,_&&(c(`todoList`)||c(`todos`)||c(`summary`)||c(`progress`))?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`待办汇总`,children:(0,L.jsxs)(`div`,{className:`space-y-1 px-2 py-1.5 text-sm text-stone-500`,children:[(0,L.jsxs)(`div`,{children:[_.count,` 条 · 进度 `,_.progress,`%`]}),(0,L.jsx)(`div`,{className:`text-xs`,children:_.summary||`—`})]})}):null,c(`note`)?(0,L.jsx)(N,{icon:(0,L.jsx)(M,{}),label:`备注`,children:(0,L.jsx)(`textarea`,{value:d.note,onChange:e=>f({...d,note:e.target.value}),rows:3,className:`w-full rounded-md border border-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`})}):null,c(`createdAt`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`创建日期`,children:(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:A(n.createdAt)})}):null,c(`updatedAt`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`修改日期`,children:(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:A(n.updatedAt)})}):null]})}function R(){let e=se(),{store:t,live:n,error:_e,setError:x,updateItem:w,createItems:j,deleteItems:M}=xe(e.ready&&e.on),N=(0,I.useMemo)(()=>({createItems:j,updateItem:w,deleteItems:M}),[j,w,M]),P=me(We,Ue),[F,Be]=he(Ge),[R,ot]=re(Ke,Je,`none`),z=R===`yearStatus`||R===`yearPriority`||R===`yearPlanType`,st=de(z),ct=(0,I.useMemo)(()=>{let e=v(z);return ae(He,P.isVisible).map(t=>t.key===`select`?{...t,width:e,min:e}:t)},[P.isVisible,z]),[B,lt]=re(qe,tt,`all`),[V,ut]=(0,I.useState)({}),[H,U]=(0,I.useState)(null),[dt,ft]=(0,I.useState)(null),[W,pt]=(0,I.useState)(!1),[G,mt]=(0,I.useState)(!1),[K,q]=(0,I.useState)(null),[ht,J]=(0,I.useState)({}),Y=u(`life.kr-tasks.cols.v13`,ct),gt=e=>{let n=e?.yearCycle?.trim()||``;return n&&Fe(t.yearCycles,n)||`—`},{submit:_t}=pe({row:K,setRow:q,submitting:G,isPristine:e=>{let t=e.base;return!e.title.trim()&&e.status===t.status&&e.priority===t.priority&&e.planType===t.planType&&e.objectiveId===t.objectiveId&&e.note===t.note},onSubmit:async e=>{mt(!0);try{await j(`krTasks`,[{title:e.title,status:e.status,priority:e.priority,planType:e.planType,objectiveId:e.objectiveId,note:e.note}]),q(null),o(`已新增 KR 任务`,`success`),x(``)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),o(`新增失败:${t}`,`error`)}finally{mt(!1)}}});function vt(e,t){let n=rt(t);q({groupKey:e,...n,base:n}),ut(t=>({...t,[e]:!1}))}let yt=c(`life.kr-tasks`),bt=(0,I.useMemo)(()=>[{value:``,label:T},...ke(t.objectives).map(e=>({value:e.id,label:e.title}))],[t.objectives]),X=(0,I.useMemo)(()=>{let e=Oe(t.krTasks,F);return B!==`all`&&(e=e.filter(e=>e.status===B)),ie(e,k)},[t.krTasks,F,B]),Z=(0,I.useMemo)(()=>{let e=e=>b(t,e.objectiveId)?.yearCycle?.trim()||``,n=e=>e?Fe(t.yearCycles,e)||`未设置年度`:Se;if(R===`none`)return[{key:`all`,label:`全部任务`,pill:`bg-stone-500 text-white`,items:X}];if(R===`status`)return k.map(e=>({key:`status:${e}`,label:E[e],pill:Xe[e],items:X.filter(t=>t.status===e)}));if(R===`priority`)return Ze.map(e=>({key:`priority:${e||`unset`}`,label:e?O[e]:C,pill:Qe[e],items:X.filter(t=>t.priority===e)}));let r=[...new Set(X.map(e))];if(r.sort((e,t)=>e?t?n(t).localeCompare(n(e),void 0,{numeric:!0}):-1:1),r.length===0)return[{key:`year:`,label:Se,pill:h(``),items:[]}];if(R===`yearStatus`)return r.map(t=>{let r=X.filter(n=>e(n)===t),i=n(t),a=k.map(e=>({key:`year:${t}|status:${e}`,label:E[e],pill:Xe[e],items:r.filter(t=>t.status===e)})).filter(e=>e.items.length>0);return{key:`year:${t}`,label:i,pill:h(t),children:a}}).filter(e=>(e.children?.length??0)>0);if(R===`yearPlanType`){let i=Le(t.planTypes).map(e=>e.id),a=new Set(i),o=[...new Set(X.map(e=>e.planType||``).filter(e=>e&&!a.has(e)))].sort((e,n)=>(ze(t.planTypes,e)||e).localeCompare(ze(t.planTypes,n)||n,`zh`)),s=[...i,...o,``];return r.map(r=>{let i=X.filter(t=>e(t)===r),a=n(r),o=s.map(e=>({key:`year:${r}|planType:${e||`unset`}`,label:e?ze(t.planTypes,e)||e:C,pill:h(e),items:i.filter(t=>(t.planType||``)===e)})).filter(e=>e.items.length>0);return{key:`year:${r}`,label:a,pill:h(r),children:o}}).filter(e=>(e.children?.length??0)>0)}return r.map(t=>{let r=X.filter(n=>e(n)===t),i=n(t),a=Ze.map(e=>({key:`year:${t}|priority:${e||`unset`}`,label:e?O[e]:C,pill:Qe[e],items:r.filter(t=>t.priority===e)})).filter(e=>e.items.length>0);return{key:`year:${t}`,label:i,pill:h(t),children:a}}).filter(e=>(e.children?.length??0)>0)},[R,X,t]),xt=(0,I.useMemo)(()=>ce(Z,R===`none`?{}:V),[Z,V,R]),St=(0,I.useMemo)(()=>ne(Z,R===`none`?{}:V),[Z,V,R]),Q=m(St);async function $(e,t){try{await w(`krTasks`,e,t),J(t=>{let n={...t};return delete n[e],n}),x(``)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),o(`保存失败:${t}`,`error`)}}function Ct(e){return{...e,...ht[e.id]}}function wt(e,t){J(n=>({...n,[e]:{...n[e],...t}}))}async function Tt(e){let t=ht[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await $(e.id,{...t,title:n}):x(`任务描述不能为空`)}async function Et(e,t){await w(`krTasks`,t,e),o(`已保存`,`success`)}function Dt(){if(!K)return null;let e=b(t,K.objectiveId),n=K.priority;return(0,L.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,L.jsx)(`td`,{className:d,style:st,children:(0,L.jsx)(`input`,{autoFocus:!0,disabled:G,value:K.title,placeholder:`输入任务描述,回车或点空白处保存`,onChange:e=>q(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),_t()):e.key===`Escape`&&(e.preventDefault(),q(null))},className:ve})}),P.isVisible(`status`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:Ye,value:K.status,onChange:e=>q(t=>t&&{...t,status:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${Ee[K.status]}`,renderTrigger:()=>(0,L.jsx)(i,{text:E[K.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ae[e.value]}`})})}):null,P.isVisible(`priority`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,hideChevron:!0,ariaLabel:`重要紧急程度`,options:$e,value:K.priority,onChange:e=>q(t=>t&&{...t,priority:e}),triggerClassName:n?je:D,renderTrigger:()=>n?(0,L.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${be[n]}`,children:(0,L.jsx)(i,{text:O[n],className:`block min-w-0 truncate`})}):(0,L.jsx)(i,{text:C,className:`block min-w-0 truncate text-stone-400`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Me[e.value]}`})})}):null,P.isVisible(`planType`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ve,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:K.planType,onChange:e=>q(t=>t&&{...t,planType:e}),mutate:N})}):null,P.isVisible(`objective`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`Objective`,menuMinWidth:220,options:bt,value:K.objectiveId,onChange:e=>q(t=>t&&{...t,objectiveId:e}),triggerClassName:e?`h-8 w-full rounded-md border border-transparent px-1.5 text-sm hover:border-stone-200`:D,renderTrigger:()=>e?(0,L.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,L.jsx)(i,{text:T,className:`block min-w-0 truncate text-stone-400`})})}):null,P.isVisible(`year`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ne,{id:e?.yearCycle?.trim()||``,label:gt(e)})}):null,P.isVisible(`quarter`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{text:e?.quarter?ye[e.quarter]:`—`,muted:!e?.quarter})}):null,P.isVisible(`todoList`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(y,{text:`—`,muted:!0})}):null,P.isVisible(`todos`)?(0,L.jsx)(`td`,{className:`px-2 py-1 text-xs text-stone-400 tabular-nums`,children:`0`}):null,P.isVisible(`summary`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(y,{text:`—`,muted:!0})}):null,P.isVisible(`progress`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(_,{value:0})}):null,P.isVisible(`note`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(we,{value:K.note,onChange:e=>q(t=>t&&{...t,note:e}),onCommit:()=>void _t(),onCancel:()=>q(e=>e&&{...e,note:e.base.note})})}):null,P.isVisible(`createdAt`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(y,{text:`—`,muted:!0})}):null,P.isVisible(`updatedAt`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(y,{text:`—`,muted:!0})}):null,(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:l})]})}async function Ot(){let e=H;if(e?.length){U(null),pt(!0);try{await M(`krTasks`,e.map(e=>e.id)),Q.clear(),o(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),o(`删除失败:${t}`,`error`)}finally{pt(!1)}}}function kt(e,n,r=0){let o=Ct(e),s=b(t,o.objectiveId),c=Ce(o.id,t.krTodos),u=o.priority;return(0,L.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,L.jsx)(Te,{checked:!!Q.selected[e.id],onChange:()=>Q.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:Q.selectedIds.length>0,depth:r}),(0,L.jsx)(`td`,{className:d,style:st,children:(0,L.jsx)(oe,{value:o.title,placeholder:`任务描述`,onChange:t=>wt(e.id,{title:t}),onCommit:()=>void Tt(e),onCancel:()=>J(t=>{let n={...t};return delete n[e.id],n})})}),P.isVisible(`status`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:Ye,value:o.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${Ee[o.status]}`,renderTrigger:()=>(0,L.jsx)(i,{text:E[o.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ae[e.value]}`})})}):null,P.isVisible(`priority`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,hideChevron:!0,ariaLabel:`重要紧急程度`,options:$e,value:o.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:u?je:D,renderTrigger:()=>u?(0,L.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${be[u]}`,children:(0,L.jsx)(i,{text:O[u],className:`block min-w-0 truncate`})}):(0,L.jsx)(i,{text:C,className:`block min-w-0 truncate text-stone-400`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Me[e.value]}`})})}):null,P.isVisible(`planType`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ve,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:o.planType,onChange:t=>void $(e.id,{planType:t}),mutate:N})}):null,P.isVisible(`objective`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`Objective`,menuMinWidth:220,options:bt,value:o.objectiveId,onChange:t=>void $(e.id,{objectiveId:t}),triggerClassName:s?`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`:D,renderTrigger:()=>s?(0,L.jsx)(i,{text:s.title,className:`block min-w-0 truncate text-stone-800`}):(0,L.jsx)(i,{text:T,className:`block min-w-0 truncate text-stone-400`})})}):null,P.isVisible(`year`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ne,{id:s?.yearCycle?.trim()||``,label:gt(s)})}):null,P.isVisible(`quarter`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{text:s?.quarter?ye[s.quarter]:`—`,muted:!s?.quarter})}):null,P.isVisible(`todoList`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(i,{text:c.titles.length?c.titles.join(` · `):`—`,className:`block min-w-0 truncate text-xs text-stone-600`})}):null,P.isVisible(`todos`)?(0,L.jsx)(`td`,{className:`px-2 py-1 text-xs text-stone-600 tabular-nums`,children:c.count}):null,P.isVisible(`summary`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(i,{text:c.summary,className:`block min-w-0 truncate text-xs text-stone-500`})}):null,P.isVisible(`progress`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(_,{value:c.progress})}):null,P.isVisible(`note`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(we,{value:o.note,onChange:t=>wt(e.id,{note:t}),onCommit:()=>void Tt(e),onCancel:()=>J(t=>{let n={...t};return delete n[e.id],n})})}):null,P.isVisible(`createdAt`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(y,{text:A(e.createdAt),muted:!e.createdAt})}):null,P.isVisible(`updatedAt`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(y,{text:A(e.updatedAt),muted:!e.updatedAt})}):null,(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:l,children:(0,L.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,L.jsx)(le,{label:`编辑 ${e.title}`,disabled:W,onClick:()=>ft(e)}),(0,L.jsx)(Re,{label:`删除 ${e.title}`,disabled:W,onClick:()=>U([e])})]})})]},e.id)}let At=(0,I.useMemo)(()=>{let e={};for(let n of t.krTasks)e[n.status]=(e[n.status]??0)+1;return k.filter(t=>(e[t]??0)>0).map(t=>`${E[t]} ${e[t]}`).join(` · `)},[t.krTasks]);if(!e.ready)return(0,L.jsx)(ue,{label:`正在读取插件开关`});if(!e.on)return(0,L.jsx)(te,{children:fe()});if(n===null)return(0,L.jsx)(ue,{label:`正在连接人生管理服务`});if(!n)return(0,L.jsx)(te,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let jt=ct.length;return(0,L.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 text-sm text-stone-600`,children:[`共 `,(0,L.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.krTasks.length}),` 条`,At?(0,L.jsxs)(`span`,{className:`text-stone-400`,children:[` · `,At]}):null]}),(0,L.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`input`,{value:F,onChange:e=>Be(e.target.value),placeholder:`搜索 KR 任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,L.jsx)(a,{flat:!0,className:`w-[148px]`,ariaLabel:`分组方式`,options:et,value:R,onChange:e=>ot(e)}),(0,L.jsx)(g,{fields:P.fields,isVisible:P.isVisible,onToggle:P.toggle}),(0,L.jsx)(a,{flat:!0,className:`w-[120px]`,ariaLabel:`状态筛选`,options:nt,value:B,onChange:e=>lt(e)}),(0,L.jsx)(`button`,{type:`button`,disabled:W||Q.selectedIds.length===0,onClick:()=>U(t.krTasks.filter(e=>Q.selected[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,L.jsx)(`button`,{type:`button`,disabled:W||G,onClick:()=>{let e=xt.find(e=>e.items!==void 0);vt(e?.key??`all`,e?it(e.key):void 0)},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:`+ 新建任务`})]})]}),(0,L.jsx)(Ie,{error:_e,onDismiss:()=>x(``)}),(0,L.jsx)(`div`,{ref:yt,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,L.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:Y.tableStyle,children:[(0,L.jsx)(`colgroup`,{children:ct.map(e=>(0,L.jsx)(`col`,{style:e.key===`select`?{width:v(z)}:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,L.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(ee,{checked:Q.allVisibleSelected,indeterminate:Q.selectedIds.length>0&&!Q.allVisibleSelected,onChange:()=>Q.toggleAllVisible(),nested:z}),(0,L.jsxs)(`th`,{className:`${f} text-xs text-stone-500`,style:st,children:[`任务描述`,(0,L.jsx)(p,{...Y.resizeProps(`title`)})]}),P.isVisible(`status`)?(0,L.jsxs)(`th`,{className:S,children:[`状态`,(0,L.jsx)(p,{...Y.resizeProps(`status`)})]}):null,P.isVisible(`priority`)?(0,L.jsxs)(`th`,{className:S,children:[`重要紧急程度`,(0,L.jsx)(p,{...Y.resizeProps(`priority`)})]}):null,P.isVisible(`planType`)?(0,L.jsxs)(`th`,{className:S,children:[`计划类型`,(0,L.jsx)(p,{...Y.resizeProps(`planType`)})]}):null,P.isVisible(`objective`)?(0,L.jsxs)(`th`,{className:De,children:[`Objective`,(0,L.jsx)(p,{...Y.resizeProps(`objective`)})]}):null,P.isVisible(`year`)?(0,L.jsxs)(`th`,{className:S,children:[`年度周期`,(0,L.jsx)(p,{...Y.resizeProps(`year`)})]}):null,P.isVisible(`quarter`)?(0,L.jsxs)(`th`,{className:S,children:[`季度周期`,(0,L.jsx)(p,{...Y.resizeProps(`quarter`)})]}):null,P.isVisible(`todoList`)?(0,L.jsxs)(`th`,{className:De,children:[`待办列表`,(0,L.jsx)(p,{...Y.resizeProps(`todoList`)})]}):null,P.isVisible(`todos`)?(0,L.jsxs)(`th`,{className:S,children:[`待办数`,(0,L.jsx)(p,{...Y.resizeProps(`todos`)})]}):null,P.isVisible(`summary`)?(0,L.jsxs)(`th`,{className:S,children:[`待办摘要`,(0,L.jsx)(p,{...Y.resizeProps(`summary`)})]}):null,P.isVisible(`progress`)?(0,L.jsxs)(`th`,{className:De,children:[`完成度`,(0,L.jsx)(p,{...Y.resizeProps(`progress`)})]}):null,P.isVisible(`note`)?(0,L.jsxs)(`th`,{className:S,children:[`备注`,(0,L.jsx)(p,{...Y.resizeProps(`note`)})]}):null,P.isVisible(`createdAt`)?(0,L.jsxs)(`th`,{className:S,children:[`创建日期`,(0,L.jsx)(p,{...Y.resizeProps(`createdAt`)})]}):null,P.isVisible(`updatedAt`)?(0,L.jsxs)(`th`,{className:S,children:[`修改日期`,(0,L.jsx)(p,{...Y.resizeProps(`updatedAt`)})]}):null,(0,L.jsx)(`th`,{"aria-hidden":`true`}),(0,L.jsx)(`th`,{className:s,children:`操作`})]})}),(0,L.jsx)(`tbody`,{children:X.length===0&&!K?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:jt,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.krTasks.length===0?`还没有 KR 任务`:`没有匹配的记录`})}):X.length===0&&K?Dt():R===`none`?(0,L.jsxs)(L.Fragment,{children:[X.map((e,t)=>kt(e,t+1)),K?Dt():(0,L.jsx)(ge,{colSpan:jt,depth:0,selectColPx:v(z),disabled:W||G,onClick:()=>vt(`all`)})]}):xt.length===0?K?Dt():null:xt.map(e=>{let t=!V[e.key];return(0,L.jsxs)(I.Fragment,{children:[(0,L.jsx)(Pe,{label:e.label,pill:e.pill,count:e.count,open:t,depth:e.depth,kind:e.kind,colSpan:jt,selectColPx:v(z),onToggle:()=>ut(t=>({...t,[e.key]:!t[e.key]}))}),e.items?.map((t,n)=>kt(t,n+1,e.depth)),e.items?K?.groupKey===e.key?Dt():X.length>0?(0,L.jsx)(ge,{colSpan:jt,depth:e.depth,selectColPx:v(z),disabled:W||G,onClick:()=>vt(e.key,it(e.key))}):null:null]},e.key)})})]})}),(0,L.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,L.jsxs)(`span`,{children:[`显示 `,X.length,` 条`,Q.selectedIds.length?` · 已选 ${Q.selectedIds.length}`:``]}),(0,L.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`待办进度由关联 KR 待办自动汇总`})]}),dt?(0,L.jsx)(at,{open:!0,item:dt,objectiveOptions:bt,store:t,mutate:N,isVisible:P.isVisible,onClose:()=>ft(null),onSave:Et}):null,(0,L.jsx)(r,{open:H!=null,title:H&&H.length>1?`批量删除`:`删除 KR 任务`,message:H&&H.length>1?`删除选中的 ${H.length} 条任务?关联待办会保留但可能失去任务关联。`:`删除「${H?.[0]?.title??``}」?关联待办会保留但可能失去任务关联。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>U(null),onConfirm:()=>void Ot()})]})}export{R as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.TgxIOKMD.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{c as s,d as c,i as l,l as u,n as d,o as f,t as p}from"./ColumnResize.CkE59sGq.js";import{$ as m,A as ee,B as h,C as g,D as _,E as te,H as v,I as ne,J as re,K as ie,L as ae,M as y,N as oe,Q as se,R as ce,S as le,T as ue,U as de,V as fe,W as b,X as pe,Y as me,Z as he,_ as ge,at as _e,b as x,c as ve,ct as ye,d as be,et as xe,f as S,g as Se,h as C,ht as Ce,j as we,k as Te,l as w,m as T,n as Ee,nt as E,o as D,ot as O,p as De,pt as Oe,q as ke,r as Ae,s as je,tt as k,u as Me,v as Ne,w as Pe,wt as Fe,x as Ie,xt as Le,y as Re,yt as ze,z as A}from"./LifeShared.SnLIiFdN.js";import{c as j,l as M,n as N,r as P,s as F,t as Be}from"./DrawerField.CiHAvXHQ.js";import{t as Ve}from"./LifePlanTypeSelect.BGtEEsL-.js";var I=e(t(),1),L=n(),He=[{key:`select`,width:36,min:32},{key:`title`,width:220,min:160},{key:`status`,width:104,min:76},{key:`priority`,width:104,min:84},{key:`planType`,width:112,min:88},{key:`objective`,width:160,min:100},{key:`year`,width:88,min:72},{key:`quarter`,width:120,min:88},{key:`todoList`,width:180,min:120},{key:`todos`,width:72,min:56},{key:`summary`,width:160,min:100},{key:`progress`,width:120,min:96},{key:`note`,width:120,min:88},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Ue=[{key:`status`,label:`状态`},{key:`priority`,label:`重要紧急程度`},{key:`planType`,label:`计划类型`},{key:`objective`,label:`所属目标`},{key:`year`,label:`年度周期`},{key:`quarter`,label:`季度周期`},{key:`todoList`,label:`待办列表`},{key:`todos`,label:`待办数`},{key:`summary`,label:`待办摘要`},{key:`progress`,label:`完成度`},{key:`note`,label:`备注`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],We=`life.kr-tasks.fields`,Ge=`life.kr-tasks.search`,Ke=`life.kr-tasks.group`,qe=`life.kr-tasks.status`,Je=[`yearStatus`,`yearPriority`,`yearPlanType`,`status`,`priority`,`none`],Ye=k.map(e=>({value:e,label:E[e]})),Xe=Ee,Ze=[`urgent_important`,`urgent`,`important`,`normal`,``],Qe=w,$e=_e.filter(e=>e!==``).map(e=>({value:e,label:O[e]})),et=[{value:`none`,label:`不分组`},{value:`yearStatus`,label:`按年度 → 状态`},{value:`yearPriority`,label:`按年度 → 重要紧急程度`},{value:`yearPlanType`,label:`按年度 → 计划类型`},{value:`status`,label:`按状态分组`},{value:`priority`,label:`按重要紧急程度分组`}],tt=[`all`,...k],nt=[{value:`all`,label:`全部状态`},...k.map(e=>({value:e,label:E[e]}))];function rt(e){return{title:``,status:e?.status??`pool`,priority:e?.priority??``,planType:e?.planType??``,objectiveId:e?.objectiveId??``,note:e?.note??``}}function it(e){let t={},n=/(?:^|\|)status:([^|]+)/.exec(e)?.[1];n&&k.includes(n)&&(t.status=n);let r=/(?:^|\|)priority:([^|]+)/.exec(e)?.[1];r===`unset`?t.priority=``:r&&Ze.includes(r)&&(t.priority=r);let i=/(?:^|\|)planType:([^|]+)/.exec(e)?.[1];return i===`unset`?t.planType=``:i&&(t.planType=i),t}function at(e){let{open:t,item:n,objectiveOptions:r,store:o,mutate:s,isVisible:c,onClose:l,onSave:u}=e,[d,f]=(0,I.useState)(rt()),[p,m]=(0,I.useState)(!1),[ee,h]=(0,I.useState)(``);(0,I.useEffect)(()=>{t&&(h(``),m(!1),f({title:n.title,status:n.status,priority:n.priority,planType:n.planType||``,objectiveId:n.objectiveId,note:n.note}))},[t,n,o.planTypes]);let g=b(o,d.objectiveId),_=Ce(n.id,o.krTodos);async function te(){let e=d.title.trim();if(!e)h(`请填写任务描述`);else{m(!0);try{await u({...d,title:e},n.id),l()}catch(e){h(e instanceof Error?e.message:String(e))}finally{m(!1)}}}return(0,L.jsxs)(x,{open:t,title:`任务详情`,onClose:l,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:l,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void te(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:`保存`})]}),children:[ee?(0,L.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:ee}):null,(0,L.jsx)(N,{icon:(0,L.jsx)(M,{}),label:`任务描述`,children:(0,L.jsx)(`input`,{autoFocus:!0,value:d.title,onChange:e=>f({...d,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),te())},placeholder:`请输入内容`,className:Be})}),c(`status`)?(0,L.jsx)(N,{icon:(0,L.jsx)(F,{}),label:`任务状态`,children:(0,L.jsx)(P,{ariaLabel:`任务状态`,options:Ye,value:d.status,onChange:e=>f({...d,status:e}),label:E[d.status],optionDotClassName:e=>Ae[e]})}):null,c(`priority`)?(0,L.jsx)(N,{icon:(0,L.jsx)(F,{}),label:`重要紧急程度`,children:(0,L.jsx)(P,{ariaLabel:`重要紧急程度`,options:$e,value:d.priority,onChange:e=>f({...d,priority:e}),label:d.priority?O[d.priority]:C,optionDotClassName:e=>Me[e]})}):null,c(`planType`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`任务类型`,children:(0,L.jsx)(Ve,{flat:!0,className:`w-full`,ariaLabel:`任务类型`,planTypes:o.planTypes,value:d.planType,onChange:e=>f({...d,planType:e}),mutate:s,renderTrigger:(e,{empty:t})=>(0,L.jsx)(i,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,c(`objective`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`所属目标`,children:(0,L.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`所属目标`,options:r,value:d.objectiveId,onChange:e=>f({...d,objectiveId:e}),className:`w-full`,triggerClassName:d.objectiveId?void 0:D,renderTrigger:()=>d.objectiveId&&g?(0,L.jsx)(i,{text:g.title,className:`block min-w-0 truncate text-stone-800`}):(0,L.jsx)(i,{text:T,className:`block min-w-0 truncate text-stone-400`})})}):null,c(`year`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`年度周期`,children:(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:g?.yearCycle?.trim()&&Fe(o.yearCycles,g.yearCycle)||`—`})}):null,c(`quarter`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`季度周期`,children:(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:g?.quarter?ye[g.quarter]:`—`})}):null,_&&(c(`todoList`)||c(`todos`)||c(`summary`)||c(`progress`))?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`待办汇总`,children:(0,L.jsxs)(`div`,{className:`space-y-1 px-2 py-1.5 text-sm text-stone-500`,children:[(0,L.jsxs)(`div`,{children:[_.count,` 条 · 进度 `,_.progress,`%`]}),(0,L.jsx)(`div`,{className:`text-xs`,children:_.summary||`—`})]})}):null,c(`note`)?(0,L.jsx)(N,{icon:(0,L.jsx)(M,{}),label:`备注`,children:(0,L.jsx)(`textarea`,{value:d.note,onChange:e=>f({...d,note:e.target.value}),rows:3,className:`w-full rounded-md border border-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`})}):null,c(`createdAt`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`创建日期`,children:(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:A(n.createdAt)})}):null,c(`updatedAt`)?(0,L.jsx)(N,{icon:(0,L.jsx)(j,{}),label:`修改日期`,children:(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:A(n.updatedAt)})}):null]})}function R(){let e=se(),{store:t,live:n,error:_e,setError:x,updateItem:w,createItems:j,deleteItems:M}=xe(e.ready&&e.on),N=(0,I.useMemo)(()=>({createItems:j,updateItem:w,deleteItems:M}),[j,w,M]),P=me(We,Ue),[F,Be]=he(Ge),[R,ot]=re(Ke,Je,`none`),z=R===`yearStatus`||R===`yearPriority`||R===`yearPlanType`,st=de(z),ct=(0,I.useMemo)(()=>{let e=v(z);return ae(He,P.isVisible).map(t=>t.key===`select`?{...t,width:e,min:e}:t)},[P.isVisible,z]),[B,lt]=re(qe,tt,`all`),[V,ut]=(0,I.useState)({}),[H,U]=(0,I.useState)(null),[dt,ft]=(0,I.useState)(null),[W,pt]=(0,I.useState)(!1),[G,mt]=(0,I.useState)(!1),[K,q]=(0,I.useState)(null),[ht,J]=(0,I.useState)({}),Y=u(`life.kr-tasks.cols.v13`,ct),gt=e=>{let n=e?.yearCycle?.trim()||``;return n&&Fe(t.yearCycles,n)||`—`},{submit:_t}=pe({row:K,setRow:q,submitting:G,isPristine:e=>{let t=e.base;return!e.title.trim()&&e.status===t.status&&e.priority===t.priority&&e.planType===t.planType&&e.objectiveId===t.objectiveId&&e.note===t.note},onSubmit:async e=>{mt(!0);try{await j(`krTasks`,[{title:e.title,status:e.status,priority:e.priority,planType:e.planType,objectiveId:e.objectiveId,note:e.note}]),q(null),o(`已新增 KR 任务`,`success`),x(``)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),o(`新增失败:${t}`,`error`)}finally{mt(!1)}}});function vt(e,t){let n=rt(t);q({groupKey:e,...n,base:n}),ut(t=>({...t,[e]:!1}))}let yt=c(`life.kr-tasks`),bt=(0,I.useMemo)(()=>[{value:``,label:T},...ke(t.objectives).map(e=>({value:e.id,label:e.title}))],[t.objectives]),X=(0,I.useMemo)(()=>{let e=Oe(t.krTasks,F);return B!==`all`&&(e=e.filter(e=>e.status===B)),ie(e,k)},[t.krTasks,F,B]),Z=(0,I.useMemo)(()=>{let e=e=>b(t,e.objectiveId)?.yearCycle?.trim()||``,n=e=>e?Fe(t.yearCycles,e)||`未设置年度`:Se;if(R===`none`)return[{key:`all`,label:`全部任务`,pill:`bg-stone-500 text-white`,items:X}];if(R===`status`)return k.map(e=>({key:`status:${e}`,label:E[e],pill:Xe[e],items:X.filter(t=>t.status===e)}));if(R===`priority`)return Ze.map(e=>({key:`priority:${e||`unset`}`,label:e?O[e]:C,pill:Qe[e],items:X.filter(t=>t.priority===e)}));let r=[...new Set(X.map(e))];if(r.sort((e,t)=>e?t?n(t).localeCompare(n(e),void 0,{numeric:!0}):-1:1),r.length===0)return[{key:`year:`,label:Se,pill:h(``),items:[]}];if(R===`yearStatus`)return r.map(t=>{let r=X.filter(n=>e(n)===t),i=n(t),a=k.map(e=>({key:`year:${t}|status:${e}`,label:E[e],pill:Xe[e],items:r.filter(t=>t.status===e)})).filter(e=>e.items.length>0);return{key:`year:${t}`,label:i,pill:h(t),children:a}}).filter(e=>(e.children?.length??0)>0);if(R===`yearPlanType`){let i=Le(t.planTypes).map(e=>e.id),a=new Set(i),o=[...new Set(X.map(e=>e.planType||``).filter(e=>e&&!a.has(e)))].sort((e,n)=>(ze(t.planTypes,e)||e).localeCompare(ze(t.planTypes,n)||n,`zh`)),s=[...i,...o,``];return r.map(r=>{let i=X.filter(t=>e(t)===r),a=n(r),o=s.map(e=>({key:`year:${r}|planType:${e||`unset`}`,label:e?ze(t.planTypes,e)||e:C,pill:h(e),items:i.filter(t=>(t.planType||``)===e)})).filter(e=>e.items.length>0);return{key:`year:${r}`,label:a,pill:h(r),children:o}}).filter(e=>(e.children?.length??0)>0)}return r.map(t=>{let r=X.filter(n=>e(n)===t),i=n(t),a=Ze.map(e=>({key:`year:${t}|priority:${e||`unset`}`,label:e?O[e]:C,pill:Qe[e],items:r.filter(t=>t.priority===e)})).filter(e=>e.items.length>0);return{key:`year:${t}`,label:i,pill:h(t),children:a}}).filter(e=>(e.children?.length??0)>0)},[R,X,t]),xt=(0,I.useMemo)(()=>ce(Z,R===`none`?{}:V),[Z,V,R]),St=(0,I.useMemo)(()=>ne(Z,R===`none`?{}:V),[Z,V,R]),Q=m(St);async function $(e,t){try{await w(`krTasks`,e,t),J(t=>{let n={...t};return delete n[e],n}),x(``)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),o(`保存失败:${t}`,`error`)}}function Ct(e){return{...e,...ht[e.id]}}function wt(e,t){J(n=>({...n,[e]:{...n[e],...t}}))}async function Tt(e){let t=ht[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await $(e.id,{...t,title:n}):x(`任务描述不能为空`)}async function Et(e,t){await w(`krTasks`,t,e),o(`已保存`,`success`)}function Dt(){if(!K)return null;let e=b(t,K.objectiveId),n=K.priority;return(0,L.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,L.jsx)(`td`,{className:d,style:st,children:(0,L.jsx)(`input`,{autoFocus:!0,disabled:G,value:K.title,placeholder:`输入任务描述,回车或点空白处保存`,onChange:e=>q(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),_t()):e.key===`Escape`&&(e.preventDefault(),q(null))},className:ve})}),P.isVisible(`status`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:Ye,value:K.status,onChange:e=>q(t=>t&&{...t,status:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${Ee[K.status]}`,renderTrigger:()=>(0,L.jsx)(i,{text:E[K.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ae[e.value]}`})})}):null,P.isVisible(`priority`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,hideChevron:!0,ariaLabel:`重要紧急程度`,options:$e,value:K.priority,onChange:e=>q(t=>t&&{...t,priority:e}),triggerClassName:n?je:D,renderTrigger:()=>n?(0,L.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${be[n]}`,children:(0,L.jsx)(i,{text:O[n],className:`block min-w-0 truncate`})}):(0,L.jsx)(i,{text:C,className:`block min-w-0 truncate text-stone-400`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Me[e.value]}`})})}):null,P.isVisible(`planType`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ve,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:K.planType,onChange:e=>q(t=>t&&{...t,planType:e}),mutate:N})}):null,P.isVisible(`objective`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`Objective`,menuMinWidth:220,options:bt,value:K.objectiveId,onChange:e=>q(t=>t&&{...t,objectiveId:e}),triggerClassName:e?`h-8 w-full rounded-md border border-transparent px-1.5 text-sm hover:border-stone-200`:D,renderTrigger:()=>e?(0,L.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,L.jsx)(i,{text:T,className:`block min-w-0 truncate text-stone-400`})})}):null,P.isVisible(`year`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ne,{id:e?.yearCycle?.trim()||``,label:gt(e)})}):null,P.isVisible(`quarter`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{text:e?.quarter?ye[e.quarter]:`—`,muted:!e?.quarter})}):null,P.isVisible(`todoList`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(y,{text:`—`,muted:!0})}):null,P.isVisible(`todos`)?(0,L.jsx)(`td`,{className:`px-2 py-1 text-xs text-stone-400 tabular-nums`,children:`0`}):null,P.isVisible(`summary`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(y,{text:`—`,muted:!0})}):null,P.isVisible(`progress`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(_,{value:0})}):null,P.isVisible(`note`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(we,{value:K.note,onChange:e=>q(t=>t&&{...t,note:e}),onCommit:()=>void _t(),onCancel:()=>q(e=>e&&{...e,note:e.base.note})})}):null,P.isVisible(`createdAt`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(y,{text:`—`,muted:!0})}):null,P.isVisible(`updatedAt`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(y,{text:`—`,muted:!0})}):null,(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:l})]})}async function Ot(){let e=H;if(e?.length){U(null),pt(!0);try{await M(`krTasks`,e.map(e=>e.id)),Q.clear(),o(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);x(t),o(`删除失败:${t}`,`error`)}finally{pt(!1)}}}function kt(e,n,r=0){let o=Ct(e),s=b(t,o.objectiveId),c=Ce(o.id,t.krTodos),u=o.priority;return(0,L.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,L.jsx)(Te,{checked:!!Q.selected[e.id],onChange:()=>Q.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:Q.selectedIds.length>0,depth:r}),(0,L.jsx)(`td`,{className:d,style:st,children:(0,L.jsx)(oe,{value:o.title,placeholder:`任务描述`,onChange:t=>wt(e.id,{title:t}),onCommit:()=>void Tt(e),onCancel:()=>J(t=>{let n={...t};return delete n[e.id],n})})}),P.isVisible(`status`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:Ye,value:o.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${Ee[o.status]}`,renderTrigger:()=>(0,L.jsx)(i,{text:E[o.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ae[e.value]}`})})}):null,P.isVisible(`priority`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,hideChevron:!0,ariaLabel:`重要紧急程度`,options:$e,value:o.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:u?je:D,renderTrigger:()=>u?(0,L.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${be[u]}`,children:(0,L.jsx)(i,{text:O[u],className:`block min-w-0 truncate`})}):(0,L.jsx)(i,{text:C,className:`block min-w-0 truncate text-stone-400`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Me[e.value]}`})})}):null,P.isVisible(`planType`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ve,{unstyled:!0,pill:!0,planTypes:t.planTypes,value:o.planType,onChange:t=>void $(e.id,{planType:t}),mutate:N})}):null,P.isVisible(`objective`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`Objective`,menuMinWidth:220,options:bt,value:o.objectiveId,onChange:t=>void $(e.id,{objectiveId:t}),triggerClassName:s?`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`:D,renderTrigger:()=>s?(0,L.jsx)(i,{text:s.title,className:`block min-w-0 truncate text-stone-800`}):(0,L.jsx)(i,{text:T,className:`block min-w-0 truncate text-stone-400`})})}):null,P.isVisible(`year`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ne,{id:s?.yearCycle?.trim()||``,label:gt(s)})}):null,P.isVisible(`quarter`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{text:s?.quarter?ye[s.quarter]:`—`,muted:!s?.quarter})}):null,P.isVisible(`todoList`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(i,{text:c.titles.length?c.titles.join(` · `):`—`,className:`block min-w-0 truncate text-xs text-stone-600`})}):null,P.isVisible(`todos`)?(0,L.jsx)(`td`,{className:`px-2 py-1 text-xs text-stone-600 tabular-nums`,children:c.count}):null,P.isVisible(`summary`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(i,{text:c.summary,className:`block min-w-0 truncate text-xs text-stone-500`})}):null,P.isVisible(`progress`)?(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,L.jsx)(_,{value:c.progress})}):null,P.isVisible(`note`)?(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(we,{value:o.note,onChange:t=>wt(e.id,{note:t}),onCommit:()=>void Tt(e),onCancel:()=>J(t=>{let n={...t};return delete n[e.id],n})})}):null,P.isVisible(`createdAt`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(y,{text:A(e.createdAt),muted:!e.createdAt})}):null,P.isVisible(`updatedAt`)?(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(y,{text:A(e.updatedAt),muted:!e.updatedAt})}):null,(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:l,children:(0,L.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,L.jsx)(le,{label:`编辑 ${e.title}`,disabled:W,onClick:()=>ft(e)}),(0,L.jsx)(Re,{label:`删除 ${e.title}`,disabled:W,onClick:()=>U([e])})]})})]},e.id)}let At=(0,I.useMemo)(()=>{let e={};for(let n of t.krTasks)e[n.status]=(e[n.status]??0)+1;return k.filter(t=>(e[t]??0)>0).map(t=>`${E[t]} ${e[t]}`).join(` · `)},[t.krTasks]);if(!e.ready)return(0,L.jsx)(ue,{label:`正在读取插件开关`});if(!e.on)return(0,L.jsx)(te,{children:fe()});if(n===null)return(0,L.jsx)(ue,{label:`正在连接人生管理服务`});if(!n)return(0,L.jsx)(te,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let jt=ct.length;return(0,L.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 text-sm text-stone-600`,children:[`共 `,(0,L.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.krTasks.length}),` 条`,At?(0,L.jsxs)(`span`,{className:`text-stone-400`,children:[` · `,At]}):null]}),(0,L.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`input`,{value:F,onChange:e=>Be(e.target.value),placeholder:`搜索 KR 任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,L.jsx)(a,{flat:!0,className:`w-[148px]`,ariaLabel:`分组方式`,options:et,value:R,onChange:e=>ot(e)}),(0,L.jsx)(g,{fields:P.fields,isVisible:P.isVisible,onToggle:P.toggle}),(0,L.jsx)(a,{flat:!0,className:`w-[120px]`,ariaLabel:`状态筛选`,options:nt,value:B,onChange:e=>lt(e)}),(0,L.jsx)(`button`,{type:`button`,disabled:W||Q.selectedIds.length===0,onClick:()=>U(t.krTasks.filter(e=>Q.selected[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,L.jsx)(`button`,{type:`button`,disabled:W||G,onClick:()=>{let e=xt.find(e=>e.items!==void 0);vt(e?.key??`all`,e?it(e.key):void 0)},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:`+ 新建任务`})]})]}),(0,L.jsx)(Ie,{error:_e,onDismiss:()=>x(``)}),(0,L.jsx)(`div`,{ref:yt,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,L.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:Y.tableStyle,children:[(0,L.jsx)(`colgroup`,{children:ct.map(e=>(0,L.jsx)(`col`,{style:e.key===`select`?{width:v(z)}:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,L.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(ee,{checked:Q.allVisibleSelected,indeterminate:Q.selectedIds.length>0&&!Q.allVisibleSelected,onChange:()=>Q.toggleAllVisible(),nested:z}),(0,L.jsxs)(`th`,{className:`${f} text-xs text-stone-500`,style:st,children:[`任务描述`,(0,L.jsx)(p,{...Y.resizeProps(`title`)})]}),P.isVisible(`status`)?(0,L.jsxs)(`th`,{className:S,children:[`状态`,(0,L.jsx)(p,{...Y.resizeProps(`status`)})]}):null,P.isVisible(`priority`)?(0,L.jsxs)(`th`,{className:S,children:[`重要紧急程度`,(0,L.jsx)(p,{...Y.resizeProps(`priority`)})]}):null,P.isVisible(`planType`)?(0,L.jsxs)(`th`,{className:S,children:[`计划类型`,(0,L.jsx)(p,{...Y.resizeProps(`planType`)})]}):null,P.isVisible(`objective`)?(0,L.jsxs)(`th`,{className:De,children:[`Objective`,(0,L.jsx)(p,{...Y.resizeProps(`objective`)})]}):null,P.isVisible(`year`)?(0,L.jsxs)(`th`,{className:S,children:[`年度周期`,(0,L.jsx)(p,{...Y.resizeProps(`year`)})]}):null,P.isVisible(`quarter`)?(0,L.jsxs)(`th`,{className:S,children:[`季度周期`,(0,L.jsx)(p,{...Y.resizeProps(`quarter`)})]}):null,P.isVisible(`todoList`)?(0,L.jsxs)(`th`,{className:De,children:[`待办列表`,(0,L.jsx)(p,{...Y.resizeProps(`todoList`)})]}):null,P.isVisible(`todos`)?(0,L.jsxs)(`th`,{className:S,children:[`待办数`,(0,L.jsx)(p,{...Y.resizeProps(`todos`)})]}):null,P.isVisible(`summary`)?(0,L.jsxs)(`th`,{className:S,children:[`待办摘要`,(0,L.jsx)(p,{...Y.resizeProps(`summary`)})]}):null,P.isVisible(`progress`)?(0,L.jsxs)(`th`,{className:De,children:[`完成度`,(0,L.jsx)(p,{...Y.resizeProps(`progress`)})]}):null,P.isVisible(`note`)?(0,L.jsxs)(`th`,{className:S,children:[`备注`,(0,L.jsx)(p,{...Y.resizeProps(`note`)})]}):null,P.isVisible(`createdAt`)?(0,L.jsxs)(`th`,{className:S,children:[`创建日期`,(0,L.jsx)(p,{...Y.resizeProps(`createdAt`)})]}):null,P.isVisible(`updatedAt`)?(0,L.jsxs)(`th`,{className:S,children:[`修改日期`,(0,L.jsx)(p,{...Y.resizeProps(`updatedAt`)})]}):null,(0,L.jsx)(`th`,{"aria-hidden":`true`}),(0,L.jsx)(`th`,{className:s,children:`操作`})]})}),(0,L.jsx)(`tbody`,{children:X.length===0&&!K?(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:jt,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.krTasks.length===0?`还没有 KR 任务`:`没有匹配的记录`})}):X.length===0&&K?Dt():R===`none`?(0,L.jsxs)(L.Fragment,{children:[X.map((e,t)=>kt(e,t+1)),K?Dt():(0,L.jsx)(ge,{colSpan:jt,depth:0,selectColPx:v(z),disabled:W||G,onClick:()=>vt(`all`)})]}):xt.length===0?K?Dt():null:xt.map(e=>{let t=!V[e.key];return(0,L.jsxs)(I.Fragment,{children:[(0,L.jsx)(Pe,{label:e.label,pill:e.pill,count:e.count,open:t,depth:e.depth,kind:e.kind,colSpan:jt,selectColPx:v(z),onToggle:()=>ut(t=>({...t,[e.key]:!t[e.key]}))}),e.items?.map((t,n)=>kt(t,n+1,e.depth)),e.items?K?.groupKey===e.key?Dt():X.length>0?(0,L.jsx)(ge,{colSpan:jt,depth:e.depth,selectColPx:v(z),disabled:W||G,onClick:()=>vt(e.key,it(e.key))}):null:null]},e.key)})})]})}),(0,L.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,L.jsxs)(`span`,{children:[`显示 `,X.length,` 条`,Q.selectedIds.length?` · 已选 ${Q.selectedIds.length}`:``]}),(0,L.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`待办进度由关联 KR 待办自动汇总`})]}),dt?(0,L.jsx)(at,{open:!0,item:dt,objectiveOptions:bt,store:t,mutate:N,isVisible:P.isVisible,onClose:()=>ft(null),onSave:Et}):null,(0,L.jsx)(r,{open:H!=null,title:H&&H.length>1?`批量删除`:`删除 KR 任务`,message:H&&H.length>1?`删除选中的 ${H.length} 条任务?关联待办会保留但可能失去任务关联。`:`删除「${H?.[0]?.title??``}」?关联待办会保留但可能失去任务关联。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>U(null),onConfirm:()=>void Ot()})]})}export{R as default};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.TgxIOKMD.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{c as s,d as c,i as ee,l,n as u,o as te,t as d}from"./ColumnResize.CkE59sGq.js";import{$ as ne,A as f,B as p,C as re,Ct as m,E as h,H as g,I as ie,J as ae,K as oe,L as se,M as _,N as ce,Q as le,R as ue,S as de,T as fe,U as pe,V as me,W as v,X as he,Y as ge,Z as _e,_ as ve,a as ye,b as be,c as xe,ct as Se,et as Ce,f as y,ft as b,g as we,i as Te,it as x,j as Ee,k as De,l as Oe,m as S,mt as ke,o as Ae,ot as C,p as je,pt as Me,q as Ne,rt as w,t as T,v as Pe,w as Fe,wt as Ie,x as Le,y as Re,z as E}from"./LifeShared.Di9sdb_T.js";import{a as D,c as O,l as k,n as A,r as j,s as ze,t as M}from"./DrawerField.CiHAvXHQ.js";var N=e(t(),1),P=n(),Be=[{key:`select`,width:36,min:32},{key:`title`,width:240,min:160},{key:`status`,width:104,min:76},{key:`krTask`,width:160,min:100},{key:`year`,width:88,min:72},{key:`quarter`,width:120,min:88},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:72,min:56},{key:`note`,width:140,min:88},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Ve=[{key:`status`,label:`状态`},{key:`krTask`,label:`所属任务`},{key:`year`,label:`年度周期`},{key:`quarter`,label:`季度周期`},{key:`priority`,label:`重要紧急程度`},{key:`start`,label:`开始日期`},{key:`due`,label:`截止日期`},{key:`cycle`,label:`待办周期`},{key:`note`,label:`备注`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],He=`life.kr-todos.fields`,Ue=`life.kr-todos.search`,We=`life.kr-todos.group`,Ge=`life.kr-todos.status`,Ke=[`yearStatus`,`status`,`none`],qe=w.map(e=>({value:e,label:x[e]})),Je=Te,Ye=[{value:`none`,label:`不分组`},{value:`yearStatus`,label:`按年度 → 状态`},{value:`status`,label:`按状态分组`}],Xe=[`all`,...w],Ze=[{value:`all`,label:`全部状态`},...w.map(e=>({value:e,label:x[e]}))];function Qe(e){let t=/(?:^|\|)status:([^|]+)/.exec(e);if(!t)return{};let n=t[1];return w.includes(n)?{status:n}:{}}function $e(e){return{title:``,status:e?.status??`pending`,krTaskId:e?.krTaskId??``,startDate:e?.startDate??m(),dueDate:e?.dueDate??m(),note:e?.note??``}}function F(e,t){let n=t.krTasks.find(t=>t.id===e.krTaskId);return{task:n,objective:n?v(t,n.objectiveId):void 0}}function et(e){let{open:t,item:n,taskOptions:r,store:o,isVisible:s,onClose:c,onSave:ee}=e,[l,u]=(0,N.useState)($e()),[te,d]=(0,N.useState)(!1),[ne,f]=(0,N.useState)(``);(0,N.useEffect)(()=>{t&&(f(``),d(!1),u({title:n.title,status:n.status,krTaskId:n.krTaskId,startDate:n.startDate||m(),dueDate:n.dueDate||m(),note:n.note}))},[t,n]);let p=F(l,o),re=ke(b(l.startDate,l.dueDate));async function h(){let e=l.title.trim();if(!e)f(`请填写待办描述`);else{d(!0);try{await ee({...l,title:e},n.id),c()}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{d(!1)}}}return(0,P.jsxs)(be,{open:t,title:`待办详情`,onClose:c,footer:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,onClick:c,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,P.jsx)(`button`,{type:`button`,disabled:te,onClick:()=>void h(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:te?`保存中…`:`保存`})]}),children:[ne?(0,P.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:ne}):null,(0,P.jsx)(A,{icon:(0,P.jsx)(k,{}),label:`待办描述`,children:(0,P.jsx)(`input`,{autoFocus:!0,value:l.title,onChange:e=>u({...l,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),h())},placeholder:`请输入内容`,className:M})}),s(`status`)?(0,P.jsx)(A,{icon:(0,P.jsx)(ze,{}),label:`待办状态`,children:(0,P.jsx)(j,{ariaLabel:`待办状态`,options:qe,value:l.status,onChange:e=>u({...l,status:e}),label:x[l.status],optionDotClassName:e=>ye[e]})}):null,s(`krTask`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`所属任务`,children:(0,P.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索 KR 任务…`,ariaLabel:`所属任务`,options:r,value:l.krTaskId,onChange:e=>u({...l,krTaskId:e}),className:`w-full`,triggerClassName:l.krTaskId?void 0:Ae,renderTrigger:()=>{let e=o.krTasks.find(e=>e.id===l.krTaskId);return e?(0,P.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,P.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,s(`year`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`年度周期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:p.objective?.yearCycle?.trim()&&Ie(o.yearCycles,p.objective.yearCycle)||`—`})}):null,s(`quarter`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`季度周期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:p.objective?.quarter?Se[p.objective.quarter]:`—`})}):null,s(`priority`)?(0,P.jsx)(A,{icon:(0,P.jsx)(ze,{}),label:`重要紧急程度`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:p.task?.priority?C[p.task.priority]:`—`})}):null,s(`start`)?(0,P.jsx)(A,{icon:(0,P.jsx)(D,{}),label:`开始日期`,children:(0,P.jsx)(T,{value:l.startDate,onChange:e=>u({...l,startDate:e})})}):null,s(`due`)?(0,P.jsx)(A,{icon:(0,P.jsx)(D,{}),label:`截止日期`,children:(0,P.jsx)(T,{value:l.dueDate,onChange:e=>u({...l,dueDate:e})})}):null,s(`cycle`)?(0,P.jsx)(A,{icon:(0,P.jsx)(D,{}),label:`待办周期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:re})}):null,s(`note`)?(0,P.jsx)(A,{icon:(0,P.jsx)(k,{}),label:`备注`,children:(0,P.jsx)(`textarea`,{value:l.note,onChange:e=>u({...l,note:e.target.value}),rows:3,className:`w-full rounded-md border border-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`})}):null,s(`createdAt`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`创建日期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.createdAt)})}):null,s(`updatedAt`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`修改日期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.updatedAt)})}):null]})}function I(){let e=le(),{store:t,live:n,error:m,setError:v,updateItem:be,createItems:D,deleteItems:O}=Ce(e.ready&&e.on),[k,A]=_e(Ue),[j,ze]=ae(We,Ke,`none`),M=j===`yearStatus`,I=pe(M),[L,tt]=ae(Ge,Xe,`all`),[R,nt]=(0,N.useState)({}),[z,B]=(0,N.useState)(null),[rt,it]=(0,N.useState)(null),[V,at]=(0,N.useState)(!1),[H,ot]=(0,N.useState)(!1),[U,W]=(0,N.useState)(null),[st,G]=(0,N.useState)({}),K=ge(He,Ve),ct=(0,N.useMemo)(()=>{let e=g(M);return se(Be,K.isVisible).map(t=>t.key===`select`?{...t,width:e,min:e}:t)},[K.isVisible,M]),q=l(`life.kr-todos.cols.v12`,ct),lt=(e,n=`随任务`)=>{let r=e?.yearCycle?.trim()||``;return r&&Ie(t.yearCycles,r)||n},{submit:ut}=he({row:U,setRow:W,submitting:H,isPristine:e=>{let t=e.base;return!e.title.trim()&&e.status===t.status&&e.krTaskId===t.krTaskId&&e.startDate===t.startDate&&e.dueDate===t.dueDate&&e.note===t.note},onSubmit:async e=>{ot(!0);try{await D(`krTodos`,[{title:e.title,status:e.status,krTaskId:e.krTaskId,startDate:e.startDate,dueDate:e.dueDate,note:e.note}]),W(null),o(`已新增 KR 待办`,`success`),v(``)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),o(`新增失败:${t}`,`error`)}finally{ot(!1)}}});function dt(e,t){let n=$e(t);W({groupKey:e,...n,base:n}),nt(t=>({...t,[e]:!1}))}let ft=c(`life.kr-todos`),pt=(0,N.useMemo)(()=>[{value:``,label:S},...Ne(t.krTasks).map(e=>({value:e.id,label:e.title}))],[t.krTasks]),J=(0,N.useMemo)(()=>{let e=Me(t.krTodos,k);return L!==`all`&&(e=e.filter(e=>e.status===L)),oe(e,w)},[t.krTodos,k,L]),Y=(0,N.useMemo)(()=>{if(j===`none`)return[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:J}];if(j===`status`)return w.map(e=>({key:`status:${e}`,label:x[e],pill:Je[e],items:J.filter(t=>t.status===e)}));let e=e=>F(e,t).objective?.yearCycle?.trim()||``,n=e=>e?Ie(t.yearCycles,e)||`未设置年度`:we,r=[...new Set(J.map(e))];return r.sort((e,t)=>e?t?n(t).localeCompare(n(e),void 0,{numeric:!0}):-1:1),r.length===0?[{key:`year:`,label:we,pill:p(``),items:[]}]:r.map(t=>{let r=J.filter(n=>e(n)===t),i=n(t),a=w.map(e=>({key:`year:${t}|status:${e}`,label:x[e],pill:Je[e],items:r.filter(t=>t.status===e)})).filter(e=>e.items.length>0);return{key:`year:${t}`,label:i,pill:p(t),children:a}}).filter(e=>(e.children?.length??0)>0)},[j,J,t]),mt=(0,N.useMemo)(()=>ue(Y,j===`none`?{}:R),[Y,R,j]),ht=(0,N.useMemo)(()=>ie(Y,j===`none`?{}:R),[Y,R,j]),X=ne(ht);async function Z(e,t){try{await be(`krTodos`,e,t),G(t=>{let n={...t};return delete n[e],n}),v(``)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),o(`保存失败:${t}`,`error`)}}function gt(e){return{...e,...st[e.id]}}function _t(e,t){G(n=>({...n,[e]:{...n[e],...t}}))}async function vt(e){let t=st[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Z(e.id,{...t,title:n}):v(`待办描述不能为空`)}async function yt(e,t){await be(`krTodos`,t,e),o(`已保存`,`success`)}function Q(){if(!U)return null;let e=F(U,t),n=ke(b(U.startDate,U.dueDate)),r=e.task?.priority??``;return(0,P.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,P.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,P.jsx)(`td`,{className:u,style:I,children:(0,P.jsx)(`input`,{autoFocus:!0,disabled:H,value:U.title,placeholder:`输入待办描述,回车或点空白处保存`,onChange:e=>W(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ut()):e.key===`Escape`&&(e.preventDefault(),W(null))},className:xe})}),K.isVisible(`status`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:qe,value:U.status,onChange:e=>W(t=>t&&{...t,status:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${Te[U.status]}`,renderTrigger:()=>(0,P.jsx)(i,{text:x[U.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,P.jsx)(`span`,{className:`h-2 w-2 rounded-full ${ye[e.value]}`})})}):null,K.isVisible(`krTask`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 KR 任务…`,ariaLabel:`KR 任务`,menuMinWidth:220,options:pt,value:U.krTaskId,onChange:e=>W(t=>t&&{...t,krTaskId:e}),triggerClassName:U.krTaskId?`h-8 w-full rounded-md border border-transparent px-1.5 text-sm hover:border-stone-200`:Ae,renderTrigger:()=>{let e=t.krTasks.find(e=>e.id===U.krTaskId);return e?(0,P.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,P.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,K.isVisible(`year`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Pe,{id:e.objective?.yearCycle?.trim()||``,label:lt(e.objective),emptyLabel:`随任务`})}):null,K.isVisible(`quarter`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(_,{text:e.objective?.quarter?Se[e.objective.quarter]:`随任务`,muted:!e.objective?.quarter})}):null,K.isVisible(`priority`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:r?(0,P.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${Oe[r]}`,children:C[r]}):(0,P.jsx)(_,{text:`随任务`,muted:!0})}):null,K.isVisible(`start`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:U.startDate,onChange:e=>W(t=>t&&{...t,startDate:e})})}):null,K.isVisible(`due`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:U.dueDate,onChange:e=>W(t=>t&&{...t,dueDate:e})})}):null,K.isVisible(`cycle`)?(0,P.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:n}):null,K.isVisible(`note`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Ee,{value:U.note,onChange:e=>W(t=>t&&{...t,note:e}),onCommit:()=>void 0,onCancel:()=>void 0})}):null,K.isVisible(`createdAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:`—`,muted:!0})}):null,K.isVisible(`updatedAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:`—`,muted:!0})}):null,(0,P.jsx)(`td`,{"aria-hidden":`true`}),(0,P.jsx)(`td`,{className:ee})]})}async function bt(){let e=z;if(e?.length){B(null),at(!0);try{await O(`krTodos`,e.map(e=>e.id)),X.clear(),o(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),o(`删除失败:${t}`,`error`)}finally{at(!1)}}}function xt(e,n,r=0){let o=gt(e),s=F(o,t),c=ke(b(o.startDate,o.dueDate)),l=s.task?.priority??``;return(0,P.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,P.jsx)(De,{checked:!!X.selected[e.id],onChange:()=>X.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:X.selectedIds.length>0,depth:r}),(0,P.jsx)(`td`,{className:u,style:I,children:(0,P.jsx)(ce,{value:o.title,placeholder:`待办描述`,onChange:t=>_t(e.id,{title:t}),onCommit:()=>void vt(e),onCancel:()=>G(t=>{let n={...t};return delete n[e.id],n})})}),K.isVisible(`status`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:qe,value:o.status,onChange:t=>void Z(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${Te[o.status]}`,renderTrigger:()=>(0,P.jsx)(i,{text:x[o.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,P.jsx)(`span`,{className:`h-2 w-2 rounded-full ${ye[e.value]}`})})}):null,K.isVisible(`krTask`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 KR 任务…`,ariaLabel:`KR 任务`,menuMinWidth:220,options:pt,value:o.krTaskId,onChange:t=>void Z(e.id,{krTaskId:t}),triggerClassName:o.krTaskId?`h-8 w-full rounded-md border border-transparent px-1.5 text-sm hover:border-stone-200`:Ae,renderTrigger:()=>{let e=t.krTasks.find(e=>e.id===o.krTaskId);return e?(0,P.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,P.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,K.isVisible(`year`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Pe,{id:s.objective?.yearCycle?.trim()||``,label:lt(s.objective),emptyLabel:`随任务`})}):null,K.isVisible(`quarter`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(_,{text:s.objective?.quarter?Se[s.objective.quarter]:`随任务`,muted:!s.objective?.quarter})}):null,K.isVisible(`priority`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:l?(0,P.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${Oe[l]}`,children:C[l]}):(0,P.jsx)(_,{text:`随任务`,muted:!0})}):null,K.isVisible(`start`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:o.startDate,onChange:t=>void Z(e.id,{startDate:t})})}):null,K.isVisible(`due`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:o.dueDate,onChange:t=>void Z(e.id,{dueDate:t})})}):null,K.isVisible(`cycle`)?(0,P.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:c}):null,K.isVisible(`note`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Ee,{value:o.note,onChange:t=>_t(e.id,{note:t}),onCommit:()=>void vt(e),onCancel:()=>G(t=>{let n={...t};return delete n[e.id],n})})}):null,K.isVisible(`createdAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:E(e.createdAt),muted:!e.createdAt})}):null,K.isVisible(`updatedAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:E(e.updatedAt),muted:!e.updatedAt})}):null,(0,P.jsx)(`td`,{"aria-hidden":`true`}),(0,P.jsx)(`td`,{className:ee,children:(0,P.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,P.jsx)(de,{label:`编辑 ${e.title}`,disabled:V,onClick:()=>it(e)}),(0,P.jsx)(Re,{label:`删除 ${e.title}`,disabled:V,onClick:()=>B([e])})]})})]},e.id)}let St=(0,N.useMemo)(()=>{let e={};for(let n of t.krTodos)e[n.status]=(e[n.status]??0)+1;return w.filter(t=>(e[t]??0)>0).map(t=>`${x[t]} ${e[t]}`).join(` · `)},[t.krTodos]);if(!e.ready)return(0,P.jsx)(fe,{label:`正在读取插件开关`});if(!e.on)return(0,P.jsx)(h,{children:me()});if(n===null)return(0,P.jsx)(fe,{label:`正在连接人生管理服务`});if(!n)return(0,P.jsx)(h,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=ct.length;return(0,P.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`min-w-0 text-sm text-stone-600`,children:[`共 `,(0,P.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.krTodos.length}),` 条`,St?(0,P.jsxs)(`span`,{className:`text-stone-400`,children:[` · `,St]}):null]}),(0,P.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`input`,{value:k,onChange:e=>A(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,P.jsx)(a,{flat:!0,className:`w-[148px]`,ariaLabel:`分组方式`,options:Ye,value:j,onChange:e=>ze(e)}),(0,P.jsx)(re,{fields:K.fields,isVisible:K.isVisible,onToggle:K.toggle}),(0,P.jsx)(a,{flat:!0,className:`w-[120px]`,ariaLabel:`状态筛选`,options:Ze,value:L,onChange:e=>tt(e)}),(0,P.jsx)(`button`,{type:`button`,disabled:V||X.selectedIds.length===0,onClick:()=>B(t.krTodos.filter(e=>X.selected[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,P.jsx)(`button`,{type:`button`,disabled:V||H,onClick:()=>{let e=mt.find(e=>e.items!==void 0);dt(e?.key??`all`,e?Qe(e.key):void 0)},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:`+ 新建待办`})]})]}),(0,P.jsx)(Le,{error:m,onDismiss:()=>v(``)}),(0,P.jsx)(`div`,{ref:ft,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,P.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,P.jsx)(`colgroup`,{children:ct.map(e=>(0,P.jsx)(`col`,{style:e.key===`select`?{width:g(M)}:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,P.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(f,{checked:X.allVisibleSelected,indeterminate:X.selectedIds.length>0&&!X.allVisibleSelected,onChange:()=>X.toggleAllVisible(),nested:M}),(0,P.jsxs)(`th`,{className:`${te} text-xs text-stone-500`,style:I,children:[`待办描述`,(0,P.jsx)(d,{...q.resizeProps(`title`)})]}),K.isVisible(`status`)?(0,P.jsxs)(`th`,{className:y,children:[`状态`,(0,P.jsx)(d,{...q.resizeProps(`status`)})]}):null,K.isVisible(`krTask`)?(0,P.jsxs)(`th`,{className:je,children:[`KR 任务`,(0,P.jsx)(d,{...q.resizeProps(`krTask`)})]}):null,K.isVisible(`year`)?(0,P.jsxs)(`th`,{className:y,children:[`年度周期`,(0,P.jsx)(d,{...q.resizeProps(`year`)})]}):null,K.isVisible(`quarter`)?(0,P.jsxs)(`th`,{className:y,children:[`季度周期`,(0,P.jsx)(d,{...q.resizeProps(`quarter`)})]}):null,K.isVisible(`priority`)?(0,P.jsxs)(`th`,{className:y,children:[`重要紧急程度`,(0,P.jsx)(d,{...q.resizeProps(`priority`)})]}):null,K.isVisible(`start`)?(0,P.jsxs)(`th`,{className:je,children:[`开始日期`,(0,P.jsx)(d,{...q.resizeProps(`start`)})]}):null,K.isVisible(`due`)?(0,P.jsxs)(`th`,{className:y,children:[`截止日期`,(0,P.jsx)(d,{...q.resizeProps(`due`)})]}):null,K.isVisible(`cycle`)?(0,P.jsxs)(`th`,{className:y,children:[`周期`,(0,P.jsx)(d,{...q.resizeProps(`cycle`)})]}):null,K.isVisible(`note`)?(0,P.jsxs)(`th`,{className:je,children:[`备注`,(0,P.jsx)(d,{...q.resizeProps(`note`)})]}):null,K.isVisible(`createdAt`)?(0,P.jsxs)(`th`,{className:y,children:[`创建日期`,(0,P.jsx)(d,{...q.resizeProps(`createdAt`)})]}):null,K.isVisible(`updatedAt`)?(0,P.jsxs)(`th`,{className:y,children:[`修改日期`,(0,P.jsx)(d,{...q.resizeProps(`updatedAt`)})]}):null,(0,P.jsx)(`th`,{"aria-hidden":`true`}),(0,P.jsx)(`th`,{className:s,children:`操作`})]})}),(0,P.jsx)(`tbody`,{children:J.length===0&&!U?(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.krTodos.length===0?`还没有 KR 待办`:`没有匹配的记录`})}):J.length===0&&U?Q():j===`none`?(0,P.jsxs)(P.Fragment,{children:[J.map((e,t)=>xt(e,t+1)),U?Q():(0,P.jsx)(ve,{colSpan:$,depth:0,selectColPx:g(M),disabled:V||H,onClick:()=>dt(`all`)})]}):mt.length===0?U?Q():null:mt.map(e=>{let t=!R[e.key];return(0,P.jsxs)(N.Fragment,{children:[(0,P.jsx)(Fe,{label:e.label,pill:e.pill,count:e.count,open:t,depth:e.depth,kind:e.kind,colSpan:$,selectColPx:g(M),onToggle:()=>nt(t=>({...t,[e.key]:!t[e.key]}))}),e.items?.map((t,n)=>xt(t,n+1,e.depth)),e.items?U?.groupKey===e.key?Q():J.length>0?(0,P.jsx)(ve,{colSpan:$,depth:e.depth,selectColPx:g(M),disabled:V||H,onClick:()=>dt(e.key,Qe(e.key))}):null:null]},e.key)})})]})}),(0,P.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,P.jsxs)(`span`,{children:[`显示 `,J.length,` 条`,X.selectedIds.length?` · 已选 ${X.selectedIds.length}`:``]}),(0,P.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`年度周期 / 季度周期 / 重要紧急程度跟随关联 KR 任务与 Objective`})]}),rt?(0,P.jsx)(et,{open:!0,item:rt,taskOptions:pt,store:t,isVisible:K.isVisible,onClose:()=>it(null),onSave:yt}):null,(0,P.jsx)(r,{open:z!=null,title:z&&z.length>1?`批量删除`:`删除 KR 待办`,message:z&&z.length>1?`删除选中的 ${z.length} 条待办?此操作不可恢复。`:`删除「${z?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>B(null),onConfirm:()=>void bt()})]})}export{I as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.TgxIOKMD.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{c as s,d as c,i as ee,l,n as u,o as te,t as d}from"./ColumnResize.CkE59sGq.js";import{$ as ne,A as f,B as p,C as re,Ct as m,E as h,H as g,I as ie,J as ae,K as oe,L as se,M as _,N as ce,Q as le,R as ue,S as de,T as fe,U as pe,V as me,W as v,X as he,Y as ge,Z as _e,_ as ve,a as ye,b as be,c as xe,ct as Se,et as Ce,f as y,ft as b,g as we,i as Te,it as x,j as Ee,k as De,l as Oe,m as S,mt as ke,o as Ae,ot as C,p as je,pt as Me,q as Ne,rt as w,t as T,v as Pe,w as Fe,wt as Ie,x as Le,y as Re,z as E}from"./LifeShared.SnLIiFdN.js";import{a as D,c as O,l as k,n as A,r as j,s as ze,t as M}from"./DrawerField.CiHAvXHQ.js";var N=e(t(),1),P=n(),Be=[{key:`select`,width:36,min:32},{key:`title`,width:240,min:160},{key:`status`,width:104,min:76},{key:`krTask`,width:160,min:100},{key:`year`,width:88,min:72},{key:`quarter`,width:120,min:88},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:72,min:56},{key:`note`,width:140,min:88},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Ve=[{key:`status`,label:`状态`},{key:`krTask`,label:`所属任务`},{key:`year`,label:`年度周期`},{key:`quarter`,label:`季度周期`},{key:`priority`,label:`重要紧急程度`},{key:`start`,label:`开始日期`},{key:`due`,label:`截止日期`},{key:`cycle`,label:`待办周期`},{key:`note`,label:`备注`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],He=`life.kr-todos.fields`,Ue=`life.kr-todos.search`,We=`life.kr-todos.group`,Ge=`life.kr-todos.status`,Ke=[`yearStatus`,`status`,`none`],qe=w.map(e=>({value:e,label:x[e]})),Je=Te,Ye=[{value:`none`,label:`不分组`},{value:`yearStatus`,label:`按年度 → 状态`},{value:`status`,label:`按状态分组`}],Xe=[`all`,...w],Ze=[{value:`all`,label:`全部状态`},...w.map(e=>({value:e,label:x[e]}))];function Qe(e){let t=/(?:^|\|)status:([^|]+)/.exec(e);if(!t)return{};let n=t[1];return w.includes(n)?{status:n}:{}}function $e(e){return{title:``,status:e?.status??`pending`,krTaskId:e?.krTaskId??``,startDate:e?.startDate??m(),dueDate:e?.dueDate??m(),note:e?.note??``}}function F(e,t){let n=t.krTasks.find(t=>t.id===e.krTaskId);return{task:n,objective:n?v(t,n.objectiveId):void 0}}function et(e){let{open:t,item:n,taskOptions:r,store:o,isVisible:s,onClose:c,onSave:ee}=e,[l,u]=(0,N.useState)($e()),[te,d]=(0,N.useState)(!1),[ne,f]=(0,N.useState)(``);(0,N.useEffect)(()=>{t&&(f(``),d(!1),u({title:n.title,status:n.status,krTaskId:n.krTaskId,startDate:n.startDate||m(),dueDate:n.dueDate||m(),note:n.note}))},[t,n]);let p=F(l,o),re=ke(b(l.startDate,l.dueDate));async function h(){let e=l.title.trim();if(!e)f(`请填写待办描述`);else{d(!0);try{await ee({...l,title:e},n.id),c()}catch(e){let t=e instanceof Error?e.message:String(e);f(t)}finally{d(!1)}}}return(0,P.jsxs)(be,{open:t,title:`待办详情`,onClose:c,footer:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`button`,{type:`button`,onClick:c,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,P.jsx)(`button`,{type:`button`,disabled:te,onClick:()=>void h(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:te?`保存中…`:`保存`})]}),children:[ne?(0,P.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:ne}):null,(0,P.jsx)(A,{icon:(0,P.jsx)(k,{}),label:`待办描述`,children:(0,P.jsx)(`input`,{autoFocus:!0,value:l.title,onChange:e=>u({...l,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),h())},placeholder:`请输入内容`,className:M})}),s(`status`)?(0,P.jsx)(A,{icon:(0,P.jsx)(ze,{}),label:`待办状态`,children:(0,P.jsx)(j,{ariaLabel:`待办状态`,options:qe,value:l.status,onChange:e=>u({...l,status:e}),label:x[l.status],optionDotClassName:e=>ye[e]})}):null,s(`krTask`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`所属任务`,children:(0,P.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索 KR 任务…`,ariaLabel:`所属任务`,options:r,value:l.krTaskId,onChange:e=>u({...l,krTaskId:e}),className:`w-full`,triggerClassName:l.krTaskId?void 0:Ae,renderTrigger:()=>{let e=o.krTasks.find(e=>e.id===l.krTaskId);return e?(0,P.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,P.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,s(`year`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`年度周期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:p.objective?.yearCycle?.trim()&&Ie(o.yearCycles,p.objective.yearCycle)||`—`})}):null,s(`quarter`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`季度周期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:p.objective?.quarter?Se[p.objective.quarter]:`—`})}):null,s(`priority`)?(0,P.jsx)(A,{icon:(0,P.jsx)(ze,{}),label:`重要紧急程度`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:p.task?.priority?C[p.task.priority]:`—`})}):null,s(`start`)?(0,P.jsx)(A,{icon:(0,P.jsx)(D,{}),label:`开始日期`,children:(0,P.jsx)(T,{value:l.startDate,onChange:e=>u({...l,startDate:e})})}):null,s(`due`)?(0,P.jsx)(A,{icon:(0,P.jsx)(D,{}),label:`截止日期`,children:(0,P.jsx)(T,{value:l.dueDate,onChange:e=>u({...l,dueDate:e})})}):null,s(`cycle`)?(0,P.jsx)(A,{icon:(0,P.jsx)(D,{}),label:`待办周期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:re})}):null,s(`note`)?(0,P.jsx)(A,{icon:(0,P.jsx)(k,{}),label:`备注`,children:(0,P.jsx)(`textarea`,{value:l.note,onChange:e=>u({...l,note:e.target.value}),rows:3,className:`w-full rounded-md border border-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`})}):null,s(`createdAt`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`创建日期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.createdAt)})}):null,s(`updatedAt`)?(0,P.jsx)(A,{icon:(0,P.jsx)(O,{}),label:`修改日期`,children:(0,P.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.updatedAt)})}):null]})}function I(){let e=le(),{store:t,live:n,error:m,setError:v,updateItem:be,createItems:D,deleteItems:O}=Ce(e.ready&&e.on),[k,A]=_e(Ue),[j,ze]=ae(We,Ke,`none`),M=j===`yearStatus`,I=pe(M),[L,tt]=ae(Ge,Xe,`all`),[R,nt]=(0,N.useState)({}),[z,B]=(0,N.useState)(null),[rt,it]=(0,N.useState)(null),[V,at]=(0,N.useState)(!1),[H,ot]=(0,N.useState)(!1),[U,W]=(0,N.useState)(null),[st,G]=(0,N.useState)({}),K=ge(He,Ve),ct=(0,N.useMemo)(()=>{let e=g(M);return se(Be,K.isVisible).map(t=>t.key===`select`?{...t,width:e,min:e}:t)},[K.isVisible,M]),q=l(`life.kr-todos.cols.v12`,ct),lt=(e,n=`随任务`)=>{let r=e?.yearCycle?.trim()||``;return r&&Ie(t.yearCycles,r)||n},{submit:ut}=he({row:U,setRow:W,submitting:H,isPristine:e=>{let t=e.base;return!e.title.trim()&&e.status===t.status&&e.krTaskId===t.krTaskId&&e.startDate===t.startDate&&e.dueDate===t.dueDate&&e.note===t.note},onSubmit:async e=>{ot(!0);try{await D(`krTodos`,[{title:e.title,status:e.status,krTaskId:e.krTaskId,startDate:e.startDate,dueDate:e.dueDate,note:e.note}]),W(null),o(`已新增 KR 待办`,`success`),v(``)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),o(`新增失败:${t}`,`error`)}finally{ot(!1)}}});function dt(e,t){let n=$e(t);W({groupKey:e,...n,base:n}),nt(t=>({...t,[e]:!1}))}let ft=c(`life.kr-todos`),pt=(0,N.useMemo)(()=>[{value:``,label:S},...Ne(t.krTasks).map(e=>({value:e.id,label:e.title}))],[t.krTasks]),J=(0,N.useMemo)(()=>{let e=Me(t.krTodos,k);return L!==`all`&&(e=e.filter(e=>e.status===L)),oe(e,w)},[t.krTodos,k,L]),Y=(0,N.useMemo)(()=>{if(j===`none`)return[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:J}];if(j===`status`)return w.map(e=>({key:`status:${e}`,label:x[e],pill:Je[e],items:J.filter(t=>t.status===e)}));let e=e=>F(e,t).objective?.yearCycle?.trim()||``,n=e=>e?Ie(t.yearCycles,e)||`未设置年度`:we,r=[...new Set(J.map(e))];return r.sort((e,t)=>e?t?n(t).localeCompare(n(e),void 0,{numeric:!0}):-1:1),r.length===0?[{key:`year:`,label:we,pill:p(``),items:[]}]:r.map(t=>{let r=J.filter(n=>e(n)===t),i=n(t),a=w.map(e=>({key:`year:${t}|status:${e}`,label:x[e],pill:Je[e],items:r.filter(t=>t.status===e)})).filter(e=>e.items.length>0);return{key:`year:${t}`,label:i,pill:p(t),children:a}}).filter(e=>(e.children?.length??0)>0)},[j,J,t]),mt=(0,N.useMemo)(()=>ue(Y,j===`none`?{}:R),[Y,R,j]),ht=(0,N.useMemo)(()=>ie(Y,j===`none`?{}:R),[Y,R,j]),X=ne(ht);async function Z(e,t){try{await be(`krTodos`,e,t),G(t=>{let n={...t};return delete n[e],n}),v(``)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),o(`保存失败:${t}`,`error`)}}function gt(e){return{...e,...st[e.id]}}function _t(e,t){G(n=>({...n,[e]:{...n[e],...t}}))}async function vt(e){let t=st[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Z(e.id,{...t,title:n}):v(`待办描述不能为空`)}async function yt(e,t){await be(`krTodos`,t,e),o(`已保存`,`success`)}function Q(){if(!U)return null;let e=F(U,t),n=ke(b(U.startDate,U.dueDate)),r=e.task?.priority??``;return(0,P.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,P.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,P.jsx)(`td`,{className:u,style:I,children:(0,P.jsx)(`input`,{autoFocus:!0,disabled:H,value:U.title,placeholder:`输入待办描述,回车或点空白处保存`,onChange:e=>W(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ut()):e.key===`Escape`&&(e.preventDefault(),W(null))},className:xe})}),K.isVisible(`status`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:qe,value:U.status,onChange:e=>W(t=>t&&{...t,status:e}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${Te[U.status]}`,renderTrigger:()=>(0,P.jsx)(i,{text:x[U.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,P.jsx)(`span`,{className:`h-2 w-2 rounded-full ${ye[e.value]}`})})}):null,K.isVisible(`krTask`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 KR 任务…`,ariaLabel:`KR 任务`,menuMinWidth:220,options:pt,value:U.krTaskId,onChange:e=>W(t=>t&&{...t,krTaskId:e}),triggerClassName:U.krTaskId?`h-8 w-full rounded-md border border-transparent px-1.5 text-sm hover:border-stone-200`:Ae,renderTrigger:()=>{let e=t.krTasks.find(e=>e.id===U.krTaskId);return e?(0,P.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,P.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,K.isVisible(`year`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Pe,{id:e.objective?.yearCycle?.trim()||``,label:lt(e.objective),emptyLabel:`随任务`})}):null,K.isVisible(`quarter`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(_,{text:e.objective?.quarter?Se[e.objective.quarter]:`随任务`,muted:!e.objective?.quarter})}):null,K.isVisible(`priority`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:r?(0,P.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${Oe[r]}`,children:C[r]}):(0,P.jsx)(_,{text:`随任务`,muted:!0})}):null,K.isVisible(`start`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:U.startDate,onChange:e=>W(t=>t&&{...t,startDate:e})})}):null,K.isVisible(`due`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:U.dueDate,onChange:e=>W(t=>t&&{...t,dueDate:e})})}):null,K.isVisible(`cycle`)?(0,P.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:n}):null,K.isVisible(`note`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Ee,{value:U.note,onChange:e=>W(t=>t&&{...t,note:e}),onCommit:()=>void 0,onCancel:()=>void 0})}):null,K.isVisible(`createdAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:`—`,muted:!0})}):null,K.isVisible(`updatedAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:`—`,muted:!0})}):null,(0,P.jsx)(`td`,{"aria-hidden":`true`}),(0,P.jsx)(`td`,{className:ee})]})}async function bt(){let e=z;if(e?.length){B(null),at(!0);try{await O(`krTodos`,e.map(e=>e.id)),X.clear(),o(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);v(t),o(`删除失败:${t}`,`error`)}finally{at(!1)}}}function xt(e,n,r=0){let o=gt(e),s=F(o,t),c=ke(b(o.startDate,o.dueDate)),l=s.task?.priority??``;return(0,P.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,P.jsx)(De,{checked:!!X.selected[e.id],onChange:()=>X.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:X.selectedIds.length>0,depth:r}),(0,P.jsx)(`td`,{className:u,style:I,children:(0,P.jsx)(ce,{value:o.title,placeholder:`待办描述`,onChange:t=>_t(e.id,{title:t}),onCommit:()=>void vt(e),onCancel:()=>G(t=>{let n={...t};return delete n[e.id],n})})}),K.isVisible(`status`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:qe,value:o.status,onChange:t=>void Z(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${Te[o.status]}`,renderTrigger:()=>(0,P.jsx)(i,{text:x[o.status],className:`block min-w-0 truncate`}),renderOptionPrefix:e=>(0,P.jsx)(`span`,{className:`h-2 w-2 rounded-full ${ye[e.value]}`})})}):null,K.isVisible(`krTask`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索 KR 任务…`,ariaLabel:`KR 任务`,menuMinWidth:220,options:pt,value:o.krTaskId,onChange:t=>void Z(e.id,{krTaskId:t}),triggerClassName:o.krTaskId?`h-8 w-full rounded-md border border-transparent px-1.5 text-sm hover:border-stone-200`:Ae,renderTrigger:()=>{let e=t.krTasks.find(e=>e.id===o.krTaskId);return e?(0,P.jsx)(i,{text:e.title,className:`block min-w-0 truncate text-stone-800`}):(0,P.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,K.isVisible(`year`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Pe,{id:s.objective?.yearCycle?.trim()||``,label:lt(s.objective),emptyLabel:`随任务`})}):null,K.isVisible(`quarter`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(_,{text:s.objective?.quarter?Se[s.objective.quarter]:`随任务`,muted:!s.objective?.quarter})}):null,K.isVisible(`priority`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:l?(0,P.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${Oe[l]}`,children:C[l]}):(0,P.jsx)(_,{text:`随任务`,muted:!0})}):null,K.isVisible(`start`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:o.startDate,onChange:t=>void Z(e.id,{startDate:t})})}):null,K.isVisible(`due`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(T,{value:o.dueDate,onChange:t=>void Z(e.id,{dueDate:t})})}):null,K.isVisible(`cycle`)?(0,P.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:c}):null,K.isVisible(`note`)?(0,P.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,P.jsx)(Ee,{value:o.note,onChange:t=>_t(e.id,{note:t}),onCommit:()=>void vt(e),onCancel:()=>G(t=>{let n={...t};return delete n[e.id],n})})}):null,K.isVisible(`createdAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:E(e.createdAt),muted:!e.createdAt})}):null,K.isVisible(`updatedAt`)?(0,P.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,P.jsx)(_,{text:E(e.updatedAt),muted:!e.updatedAt})}):null,(0,P.jsx)(`td`,{"aria-hidden":`true`}),(0,P.jsx)(`td`,{className:ee,children:(0,P.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,P.jsx)(de,{label:`编辑 ${e.title}`,disabled:V,onClick:()=>it(e)}),(0,P.jsx)(Re,{label:`删除 ${e.title}`,disabled:V,onClick:()=>B([e])})]})})]},e.id)}let St=(0,N.useMemo)(()=>{let e={};for(let n of t.krTodos)e[n.status]=(e[n.status]??0)+1;return w.filter(t=>(e[t]??0)>0).map(t=>`${x[t]} ${e[t]}`).join(` · `)},[t.krTodos]);if(!e.ready)return(0,P.jsx)(fe,{label:`正在读取插件开关`});if(!e.on)return(0,P.jsx)(h,{children:me()});if(n===null)return(0,P.jsx)(fe,{label:`正在连接人生管理服务`});if(!n)return(0,P.jsx)(h,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=ct.length;return(0,P.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,P.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`min-w-0 text-sm text-stone-600`,children:[`共 `,(0,P.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.krTodos.length}),` 条`,St?(0,P.jsxs)(`span`,{className:`text-stone-400`,children:[` · `,St]}):null]}),(0,P.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`input`,{value:k,onChange:e=>A(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,P.jsx)(a,{flat:!0,className:`w-[148px]`,ariaLabel:`分组方式`,options:Ye,value:j,onChange:e=>ze(e)}),(0,P.jsx)(re,{fields:K.fields,isVisible:K.isVisible,onToggle:K.toggle}),(0,P.jsx)(a,{flat:!0,className:`w-[120px]`,ariaLabel:`状态筛选`,options:Ze,value:L,onChange:e=>tt(e)}),(0,P.jsx)(`button`,{type:`button`,disabled:V||X.selectedIds.length===0,onClick:()=>B(t.krTodos.filter(e=>X.selected[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,P.jsx)(`button`,{type:`button`,disabled:V||H,onClick:()=>{let e=mt.find(e=>e.items!==void 0);dt(e?.key??`all`,e?Qe(e.key):void 0)},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:`+ 新建待办`})]})]}),(0,P.jsx)(Le,{error:m,onDismiss:()=>v(``)}),(0,P.jsx)(`div`,{ref:ft,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,P.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,P.jsx)(`colgroup`,{children:ct.map(e=>(0,P.jsx)(`col`,{style:e.key===`select`?{width:g(M)}:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,P.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(f,{checked:X.allVisibleSelected,indeterminate:X.selectedIds.length>0&&!X.allVisibleSelected,onChange:()=>X.toggleAllVisible(),nested:M}),(0,P.jsxs)(`th`,{className:`${te} text-xs text-stone-500`,style:I,children:[`待办描述`,(0,P.jsx)(d,{...q.resizeProps(`title`)})]}),K.isVisible(`status`)?(0,P.jsxs)(`th`,{className:y,children:[`状态`,(0,P.jsx)(d,{...q.resizeProps(`status`)})]}):null,K.isVisible(`krTask`)?(0,P.jsxs)(`th`,{className:je,children:[`KR 任务`,(0,P.jsx)(d,{...q.resizeProps(`krTask`)})]}):null,K.isVisible(`year`)?(0,P.jsxs)(`th`,{className:y,children:[`年度周期`,(0,P.jsx)(d,{...q.resizeProps(`year`)})]}):null,K.isVisible(`quarter`)?(0,P.jsxs)(`th`,{className:y,children:[`季度周期`,(0,P.jsx)(d,{...q.resizeProps(`quarter`)})]}):null,K.isVisible(`priority`)?(0,P.jsxs)(`th`,{className:y,children:[`重要紧急程度`,(0,P.jsx)(d,{...q.resizeProps(`priority`)})]}):null,K.isVisible(`start`)?(0,P.jsxs)(`th`,{className:je,children:[`开始日期`,(0,P.jsx)(d,{...q.resizeProps(`start`)})]}):null,K.isVisible(`due`)?(0,P.jsxs)(`th`,{className:y,children:[`截止日期`,(0,P.jsx)(d,{...q.resizeProps(`due`)})]}):null,K.isVisible(`cycle`)?(0,P.jsxs)(`th`,{className:y,children:[`周期`,(0,P.jsx)(d,{...q.resizeProps(`cycle`)})]}):null,K.isVisible(`note`)?(0,P.jsxs)(`th`,{className:je,children:[`备注`,(0,P.jsx)(d,{...q.resizeProps(`note`)})]}):null,K.isVisible(`createdAt`)?(0,P.jsxs)(`th`,{className:y,children:[`创建日期`,(0,P.jsx)(d,{...q.resizeProps(`createdAt`)})]}):null,K.isVisible(`updatedAt`)?(0,P.jsxs)(`th`,{className:y,children:[`修改日期`,(0,P.jsx)(d,{...q.resizeProps(`updatedAt`)})]}):null,(0,P.jsx)(`th`,{"aria-hidden":`true`}),(0,P.jsx)(`th`,{className:s,children:`操作`})]})}),(0,P.jsx)(`tbody`,{children:J.length===0&&!U?(0,P.jsx)(`tr`,{children:(0,P.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.krTodos.length===0?`还没有 KR 待办`:`没有匹配的记录`})}):J.length===0&&U?Q():j===`none`?(0,P.jsxs)(P.Fragment,{children:[J.map((e,t)=>xt(e,t+1)),U?Q():(0,P.jsx)(ve,{colSpan:$,depth:0,selectColPx:g(M),disabled:V||H,onClick:()=>dt(`all`)})]}):mt.length===0?U?Q():null:mt.map(e=>{let t=!R[e.key];return(0,P.jsxs)(N.Fragment,{children:[(0,P.jsx)(Fe,{label:e.label,pill:e.pill,count:e.count,open:t,depth:e.depth,kind:e.kind,colSpan:$,selectColPx:g(M),onToggle:()=>nt(t=>({...t,[e.key]:!t[e.key]}))}),e.items?.map((t,n)=>xt(t,n+1,e.depth)),e.items?U?.groupKey===e.key?Q():J.length>0?(0,P.jsx)(ve,{colSpan:$,depth:e.depth,selectColPx:g(M),disabled:V||H,onClick:()=>dt(e.key,Qe(e.key))}):null:null]},e.key)})})]})}),(0,P.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,P.jsxs)(`span`,{children:[`显示 `,J.length,` 条`,X.selectedIds.length?` · 已选 ${X.selectedIds.length}`:``]}),(0,P.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`年度周期 / 季度周期 / 重要紧急程度跟随关联 KR 任务与 Objective`})]}),rt?(0,P.jsx)(et,{open:!0,item:rt,taskOptions:pt,store:t,isVisible:K.isVisible,onClose:()=>it(null),onSave:yt}):null,(0,P.jsx)(r,{open:z!=null,title:z&&z.length>1?`批量删除`:`删除 KR 待办`,message:z&&z.length>1?`删除选中的 ${z.length} 条待办?此操作不可恢复。`:`删除「${z?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>B(null),onConfirm:()=>void bt()})]})}export{I as default};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.TgxIOKMD.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{c as s,d as c,i as l,l as ee,n as u,o as d,t as f}from"./ColumnResize.CkE59sGq.js";import{$ as p,A as m,B as h,C as te,D as g,E as _,G as ne,H as v,I as re,J as ie,L as ae,M as y,N as oe,Q as se,R as ce,S as le,T as ue,U as de,V as fe,X as pe,Y as me,Z as he,_ as ge,_t as _e,b as ve,c as ye,ct as b,et as be,f as x,g as xe,h as S,k as Se,o as C,pt as Ce,s as w,st as T,vt as we,w as Te,wt as Ee,x as De,y as Oe,z as E}from"./LifeShared.Di9sdb_T.js";import{c as D,l as O,n as k,t as A}from"./DrawerField.CiHAvXHQ.js";import{t as j}from"./LifeYearCycleSelect.Q4VvLY8X.js";var M=e(t(),1),N=n(),ke=[{key:`select`,width:36,min:32},{key:`title`,width:260,min:180},{key:`yearCycle`,width:120,min:88},{key:`yearPlanId`,width:160,min:120},{key:`quarter`,width:140,min:100},{key:`keyResults`,width:220,min:140},{key:`progress`,width:120,min:96},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Ae=[{key:`yearCycle`,label:`年度周期`},{key:`yearPlanId`,label:`年度计划`},{key:`quarter`,label:`季度周期`},{key:`keyResults`,label:`关键结果`},{key:`progress`,label:`完成度`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],je=`life.objectives.fields`,Me=`life.objectives.search`,Ne=`life.objectives.group`,Pe=[`yearQuarter`,`yearCycle`,`none`],Fe=[`Q1`,`Q2`,`Q3`,`Q4`,`unset`],P={Q1:`bg-[#e1eaff] text-[#1f4ec2]`,Q2:`bg-[#d9f5d2] text-[#1d7a12]`,Q3:`bg-[#fff1e3] text-[#a85b00]`,Q4:`bg-[#fee4e3] text-[#c02a26]`,unset:`bg-stone-300 text-stone-600`};function Ie(e){return e===`Q1`||e===`Q2`||e===`Q3`||e===`Q4`?e:`unset`}var F=T.filter(e=>e!==``).map(e=>({value:e,label:b[e]})),Le=[{value:`none`,label:`不分组`},{value:`yearQuarter`,label:`按年度 → 季度周期`},{value:`yearCycle`,label:`按年度周期分组`}];function I(e){return{title:``,yearCycle:e?.yearCycle??``,yearPlanId:e?.yearPlanId??``,quarter:e?.quarter??``}}function Re(e){return[...e].sort((e,t)=>(t.updatedAt||``).localeCompare(e.updatedAt||``)).map(e=>({value:e.id,label:e.title}))}function ze(e,t){return t?e.find(e=>e.id===t)?.title??``:``}function Be(e){let t={},n=/(?:^|\|)year:([^|]*)/.exec(e);n&&(t.yearCycle=n[1]??``);let r=/(?:^|\|)quarter:([^|]+)/.exec(e)?.[1];return r===`unset`||r===`other`?t.quarter=``:(r===`Q1`||r===`Q2`||r===`Q3`||r===`Q4`)&&(t.quarter=r),t}function Ve(e){for(let t of e)if(t.children?.length){let e=Ve(t.children);if(e)return e}else if(t.items!==void 0)return t.key;return`all`}function He(e){let{open:t,item:n,yearCycles:r,yearCycleMutate:o,yearPlans:s,isVisible:c,onClose:l,onSave:ee}=e,[u,d]=(0,M.useState)(I()),[f,p]=(0,M.useState)(!1),[m,h]=(0,M.useState)(``),te=(0,M.useMemo)(()=>Re(s),[s]);(0,M.useEffect)(()=>{t&&(h(``),p(!1),d({title:n.title,yearCycle:n.yearCycle,yearPlanId:n.yearPlanId||``,quarter:n.quarter}))},[t,n]);async function g(){let e=u.title.trim();if(!e)h(`请填写目标描述`);else{p(!0);try{await ee({...u,title:e,yearCycle:u.yearCycle,yearPlanId:u.yearPlanId},n.id),l()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}}function _(e){let t=s.find(t=>t.id===e);d({...u,yearPlanId:e,yearCycle:t?.yearCycle||u.yearCycle})}return(0,N.jsxs)(ve,{open:t,title:`目标详情`,onClose:l,footer:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,onClick:l,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,N.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>void g(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:f?`保存中…`:`保存`})]}),children:[m?(0,N.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:m}):null,(0,N.jsx)(k,{icon:(0,N.jsx)(O,{}),label:`目标描述`,children:(0,N.jsx)(`input`,{autoFocus:!0,value:u.title,onChange:e=>d({...u,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())},placeholder:`请输入内容`,className:A})}),c(`yearCycle`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`年度周期`,children:(0,N.jsx)(j,{flat:!0,className:`w-full`,yearCycles:r,value:u.yearCycle,onChange:e=>{let t=s.find(e=>e.id===u.yearPlanId),n=!!(u.yearPlanId&&t?.yearCycle&&t.yearCycle!==e);d({...u,yearCycle:e,...n?{yearPlanId:``}:null})},mutate:o,renderTrigger:(e,{empty:t})=>(0,N.jsx)(i,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,c(`yearPlanId`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`年度计划`,children:(0,N.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索年度计划…`,ariaLabel:`年度计划`,options:te,value:u.yearPlanId,onChange:_,className:`w-full`,renderTrigger:()=>{let e=ze(s,u.yearPlanId);return(0,N.jsx)(i,{text:e||`未选择`,className:`block min-w-0 truncate ${e?`text-stone-800`:`text-stone-400`}`})}})}):null,c(`quarter`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`季度周期`,children:(0,N.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索季度周期…`,ariaLabel:`季度周期`,options:F,value:u.quarter,onChange:e=>d({...u,quarter:e}),className:`w-full`,renderTrigger:()=>(0,N.jsx)(i,{text:u.quarter?b[u.quarter]:S,className:`block min-w-0 truncate ${u.quarter?`text-stone-800`:`text-stone-400`}`})})}):null,c(`createdAt`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`创建日期`,children:(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.createdAt)})}):null,c(`updatedAt`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`修改日期`,children:(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.updatedAt)})}):null]})}function L(){let e=se(),{store:t,live:n,error:ve,setError:T,updateItem:D,createItems:O,deleteItems:k}=be(e.ready&&e.on),A=(0,M.useMemo)(()=>({createItems:O,updateItem:D,deleteItems:k}),[O,D,k]),I=me(je,Ae),[L,Ue]=he(Me),[R,We]=ie(Ne,Pe,`none`),[z,Ge]=(0,M.useState)({}),B=R===`yearQuarter`,Ke=de(B),qe=(0,M.useMemo)(()=>{let e=v(B);return ae(ke,I.isVisible).map(t=>t.key===`select`?{...t,width:e,min:e}:t)},[I.isVisible,B]),[V,H]=(0,M.useState)(null),[Je,Ye]=(0,M.useState)(null),[U,Xe]=(0,M.useState)(!1),[W,Ze]=(0,M.useState)(!1),[Qe,$e]=(0,M.useState)({}),[G,K]=(0,M.useState)(null),q=ee(`life.objectives.cols.v13`,qe),et=(0,M.useMemo)(()=>Re(t.yearPlans),[t.yearPlans]),tt=c(`life.objectives`),J=(0,M.useMemo)(()=>ne(Ce(t.objectives,L)),[t.objectives,L]),Y=(0,M.useMemo)(()=>{if(R===`none`)return[{key:`all`,label:`全部目标`,pill:`bg-stone-500 text-white`,items:J}];let e=e=>e.yearCycle.trim(),n=e=>e?Ee(t.yearCycles,e)||`未设置年度`:xe,r=[...new Set(J.map(e))];return r.sort((e,t)=>e?t?n(t).localeCompare(n(e),void 0,{numeric:!0}):-1:1),r.length===0?[{key:`year:`,label:xe,pill:h(``),items:[]}]:R===`yearCycle`?r.map(t=>{let r=J.filter(n=>e(n)===t),i=n(t);return{key:`year:${t}`,label:i,pill:h(t),items:r}}):r.map(t=>{let r=J.filter(n=>e(n)===t),i=n(t),a=Fe.map(e=>{let n=e===`unset`?S:b[e],i=r.filter(t=>(t.quarter||`unset`)===(e===`unset`?`unset`:e));return{key:`year:${t}|quarter:${e}`,label:n,pill:P[e],items:i}}),o=new Set(a.flatMap(e=>e.items.map(e=>e.id))),s=r.filter(e=>!o.has(e.id));return s.length>0&&a.push({key:`year:${t}|quarter:other`,label:`其它`,pill:P.unset,items:s}),{key:`year:${t}`,label:i,pill:h(t),children:a.filter(e=>e.items.length>0)}}).filter(e=>(e.children?.length??0)>0)},[R,J,t.yearCycles]),nt=(0,M.useMemo)(()=>ce(Y,R===`none`?{}:z),[Y,z,R]),rt=(0,M.useMemo)(()=>re(Y,R===`none`?{}:z),[Y,z,R]),X=p(rt),{submit:it}=pe({row:G,setRow:K,submitting:W,isPristine:e=>!e.title.trim()&&e.yearCycle===e.baseYearCycle&&e.yearPlanId===e.baseYearPlanId&&e.quarter===e.baseQuarter,onSubmit:async e=>{Ze(!0);try{await O(`objectives`,[{title:e.title,yearCycle:e.yearCycle,yearPlanId:e.yearPlanId,quarter:e.quarter}]),K(null),o(`已新增 Objective`,`success`),T(``)}catch(e){let t=e instanceof Error?e.message:String(e);T(t),o(`新增失败:${t}`,`error`)}finally{Ze(!1)}}});function at(e,t){let n=t?.yearCycle??``,r=t?.yearPlanId??``,i=t?.quarter??``;K({groupKey:e,title:``,yearCycle:n,yearPlanId:r,quarter:i,baseYearCycle:n,baseYearPlanId:r,baseQuarter:i}),Ge(t=>({...t,[e]:!1}))}function ot(e,n){return{yearPlanId:e,yearCycle:t.yearPlans.find(t=>t.id===e)?.yearCycle||n}}async function Z(e,t){try{await D(`objectives`,e,t),$e(t=>{let n={...t};return delete n[e],n}),T(``)}catch(e){let t=e instanceof Error?e.message:String(e);T(t),o(`保存失败:${t}`,`error`)}}function st(e){return{...e,...Qe[e.id]}}function ct(e,t){$e(n=>({...n,[e]:{...n[e],...t}}))}async function lt(e){let t=Qe[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Z(e.id,{...t,title:n}):T(`目标描述不能为空`)}async function ut(e,t){await D(`objectives`,t,e),o(`已保存`,`success`)}async function dt(){let e=V;if(e?.length){H(null),Xe(!0);try{await k(`objectives`,e.map(e=>e.id)),X.clear(),o(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){T(e instanceof Error?e.message:String(e))}finally{Xe(!1)}}}function Q(){return G?(0,N.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,N.jsx)(`td`,{className:u,style:Ke,children:(0,N.jsx)(`input`,{autoFocus:!0,disabled:W,value:G.title,placeholder:`输入目标名称,回车或点空白处保存`,onChange:e=>K(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),it()):e.key===`Escape`&&(e.preventDefault(),K(null))},className:ye})}),I.isVisible(`yearCycle`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(j,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:G.yearCycle,onChange:e=>K(n=>{if(!n)return n;let r=t.yearPlans.find(e=>e.id===n.yearPlanId),i=!!(n.yearPlanId&&r?.yearCycle&&r.yearCycle!==e);return{...n,yearCycle:e,...i?{yearPlanId:``}:null}}),mutate:A})}):null,I.isVisible(`yearPlanId`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索年度计划…`,ariaLabel:`年度计划`,options:et,value:G.yearPlanId,onChange:e=>K(t=>t&&{...t,...ot(e,t.yearCycle)}),triggerClassName:G.yearPlanId?w:C,renderTrigger:()=>{let e=ze(t.yearPlans,G.yearPlanId);return e?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md bg-[#e8f0fe] px-2 text-xs font-medium text-[#1f4ec2]`,children:(0,N.jsx)(i,{text:e,className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,I.isVisible(`quarter`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索季度周期…`,ariaLabel:`季度周期`,options:F,value:G.quarter,onChange:e=>K(t=>t&&{...t,quarter:e}),triggerClassName:G.quarter?w:C,renderTrigger:()=>G.quarter?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${P[Ie(G.quarter)]}`,children:(0,N.jsx)(i,{text:b[G.quarter],className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})})}):null,I.isVisible(`keyResults`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-400`,children:`—`}):null,I.isVisible(`progress`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,N.jsx)(g,{value:0})}):null,I.isVisible(`createdAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:`—`,muted:!0})}):null,I.isVisible(`updatedAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:`—`,muted:!0})}):null,(0,N.jsx)(`td`,{"aria-hidden":`true`}),(0,N.jsx)(`td`,{className:l})]}):null}function ft(e,n,r=0){let o=st(e),s=_e(o.id,t.krTasks),c=we(o.id,t.krTasks,t.krTodos);return(0,N.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,N.jsx)(Se,{checked:!!X.selected[e.id],onChange:()=>X.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:X.selectedIds.length>0,depth:r}),(0,N.jsx)(`td`,{className:u,style:Ke,children:(0,N.jsx)(oe,{value:o.title,placeholder:`目标描述`,onChange:t=>ct(e.id,{title:t}),onCommit:()=>void lt(e),onCancel:()=>$e(t=>{let n={...t};return delete n[e.id],n})})}),I.isVisible(`yearCycle`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(j,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:o.yearCycle,onChange:n=>{let r=t.yearPlans.find(e=>e.id===o.yearPlanId),i=o.yearPlanId&&r?.yearCycle&&r.yearCycle!==n?{yearCycle:n,yearPlanId:``}:{yearCycle:n};Qe[e.id]?ct(e.id,i):Z(e.id,i)},mutate:A})}):null,I.isVisible(`yearPlanId`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索年度计划…`,ariaLabel:`年度计划`,options:et,value:o.yearPlanId||``,onChange:t=>{let n=ot(t,o.yearCycle);Z(e.id,n)},triggerClassName:o.yearPlanId?w:C,renderTrigger:()=>{let e=ze(t.yearPlans,o.yearPlanId||``);return e?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md bg-[#e8f0fe] px-2 text-xs font-medium text-[#1f4ec2]`,children:(0,N.jsx)(i,{text:e,className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,I.isVisible(`quarter`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索季度周期…`,ariaLabel:`季度周期`,options:F,value:o.quarter,onChange:t=>void Z(e.id,{quarter:t}),triggerClassName:o.quarter?w:C,renderTrigger:()=>o.quarter?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${P[Ie(o.quarter)]}`,children:(0,N.jsx)(i,{text:b[o.quarter],className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})})}):null,I.isVisible(`keyResults`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,N.jsx)(i,{text:s.length?s.join(` · `):`暂无 KR 任务`,className:`block min-w-0 truncate text-xs text-stone-600`})}):null,I.isVisible(`progress`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,N.jsx)(g,{value:c})}):null,I.isVisible(`createdAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:E(e.createdAt),muted:!e.createdAt})}):null,I.isVisible(`updatedAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:E(e.updatedAt),muted:!e.updatedAt})}):null,(0,N.jsx)(`td`,{"aria-hidden":`true`}),(0,N.jsx)(`td`,{className:l,children:(0,N.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,N.jsx)(le,{label:`编辑 ${e.title}`,disabled:U,onClick:()=>Ye(e)}),(0,N.jsx)(Oe,{label:`删除 ${e.title}`,disabled:U,onClick:()=>H([e])})]})})]},e.id)}if(!e.ready)return(0,N.jsx)(ue,{label:`正在读取插件开关`});if(!e.on)return(0,N.jsx)(_,{children:fe()});if(n===null)return(0,N.jsx)(ue,{label:`正在连接人生管理服务`});if(!n)return(0,N.jsx)(_,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=qe.length;return(0,N.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,N.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,N.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.objectives.length}),` 条`]}),(0,N.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`input`,{value:L,onChange:e=>Ue(e.target.value),placeholder:`搜索 Objective…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,N.jsx)(a,{flat:!0,className:`w-[148px]`,ariaLabel:`分组方式`,options:Le,value:R,onChange:e=>We(e)}),(0,N.jsx)(te,{fields:I.fields,isVisible:I.isVisible,onToggle:I.toggle}),(0,N.jsx)(`button`,{type:`button`,disabled:U||X.selectedIds.length===0,onClick:()=>H(t.objectives.filter(e=>X.selected[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,N.jsx)(`button`,{type:`button`,disabled:U||W,onClick:()=>{let e=Ve(Y);at(e,Be(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:`+ 新建目标`})]})]}),(0,N.jsx)(De,{error:ve,onDismiss:()=>T(``)}),(0,N.jsx)(`div`,{ref:tt,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,N.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,N.jsx)(`colgroup`,{children:qe.map(e=>(0,N.jsx)(`col`,{style:e.key===`select`?{width:v(B)}:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,N.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,N.jsxs)(`tr`,{children:[(0,N.jsx)(m,{checked:X.allVisibleSelected,indeterminate:X.selectedIds.length>0&&!X.allVisibleSelected,onChange:()=>X.toggleAllVisible(),nested:B}),(0,N.jsxs)(`th`,{className:`${d} text-xs text-stone-500`,style:Ke,children:[`目标描述`,(0,N.jsx)(f,{...q.resizeProps(`title`)})]}),I.isVisible(`yearCycle`)?(0,N.jsxs)(`th`,{className:x,children:[`年度周期`,(0,N.jsx)(f,{...q.resizeProps(`yearCycle`)})]}):null,I.isVisible(`yearPlanId`)?(0,N.jsxs)(`th`,{className:x,children:[`年度计划`,(0,N.jsx)(f,{...q.resizeProps(`yearPlanId`)})]}):null,I.isVisible(`quarter`)?(0,N.jsxs)(`th`,{className:x,children:[`季度周期`,(0,N.jsx)(f,{...q.resizeProps(`quarter`)})]}):null,I.isVisible(`keyResults`)?(0,N.jsxs)(`th`,{className:x,children:[`关键结果(KR 任务)`,(0,N.jsx)(f,{...q.resizeProps(`keyResults`)})]}):null,I.isVisible(`progress`)?(0,N.jsxs)(`th`,{className:x,children:[`完成度`,(0,N.jsx)(f,{...q.resizeProps(`progress`)})]}):null,I.isVisible(`createdAt`)?(0,N.jsxs)(`th`,{className:x,children:[`创建日期`,(0,N.jsx)(f,{...q.resizeProps(`createdAt`)})]}):null,I.isVisible(`updatedAt`)?(0,N.jsxs)(`th`,{className:x,children:[`修改日期`,(0,N.jsx)(f,{...q.resizeProps(`updatedAt`)})]}):null,(0,N.jsx)(`th`,{"aria-hidden":`true`}),(0,N.jsx)(`th`,{className:s,children:`操作`})]})}),(0,N.jsx)(`tbody`,{children:J.length===0&&!G?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.objectives.length===0?`还没有 Objective`:`没有匹配的记录`})}):J.length===0&&G?Q():R===`none`?(0,N.jsxs)(N.Fragment,{children:[J.map((e,t)=>ft(e,t+1)),G?Q():(0,N.jsx)(ge,{colSpan:$,depth:0,selectColPx:v(B),disabled:U||W,onClick:()=>at(`all`)})]}):nt.length===0?G?Q():null:nt.map(e=>{let t=!z[e.key];return(0,N.jsxs)(M.Fragment,{children:[(0,N.jsx)(Te,{label:e.label,pill:e.pill,count:e.count,open:t,depth:e.depth,kind:e.kind,colSpan:$,selectColPx:v(B),onToggle:()=>Ge(t=>({...t,[e.key]:!t[e.key]}))}),e.items?.map((t,n)=>ft(t,n+1,e.depth)),e.items&&e.items.length>0?G?.groupKey===e.key?Q():(0,N.jsx)(ge,{colSpan:$,depth:e.depth,selectColPx:v(B),disabled:U||W,onClick:()=>at(e.key,Be(e.key))}):G?.groupKey===e.key?Q():null]},e.key)})})]})}),(0,N.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,N.jsxs)(`span`,{children:[`显示 `,J.length,` 条`,X.selectedIds.length?` · 已选 ${X.selectedIds.length}`:``]}),(0,N.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`选「年度计划」后,对应计划的关联 Objective 会自动带出`})]}),Je?(0,N.jsx)(He,{open:!0,item:Je,yearCycles:t.yearCycles,yearCycleMutate:A,yearPlans:t.yearPlans,isVisible:I.isVisible,onClose:()=>Ye(null),onSave:ut}):null,(0,N.jsx)(r,{open:V!=null,title:V&&V.length>1?`批量删除`:`删除 Objective`,message:V&&V.length>1?`删除选中的 ${V.length} 条目标?`:`删除「${V?.[0]?.title??``}」?`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>H(null),onConfirm:()=>void dt()})]})}export{L as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.TgxIOKMD.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{c as s,d as c,i as l,l as ee,n as u,o as d,t as f}from"./ColumnResize.CkE59sGq.js";import{$ as p,A as m,B as h,C as te,D as g,E as _,G as ne,H as v,I as re,J as ie,L as ae,M as y,N as oe,Q as se,R as ce,S as le,T as ue,U as de,V as fe,X as pe,Y as me,Z as he,_ as ge,_t as _e,b as ve,c as ye,ct as b,et as be,f as x,g as xe,h as S,k as Se,o as C,pt as Ce,s as w,st as T,vt as we,w as Te,wt as Ee,x as De,y as Oe,z as E}from"./LifeShared.SnLIiFdN.js";import{c as D,l as O,n as k,t as A}from"./DrawerField.CiHAvXHQ.js";import{t as j}from"./LifeYearCycleSelect.CuiWO8Tc.js";var M=e(t(),1),N=n(),ke=[{key:`select`,width:36,min:32},{key:`title`,width:260,min:180},{key:`yearCycle`,width:120,min:88},{key:`yearPlanId`,width:160,min:120},{key:`quarter`,width:140,min:100},{key:`keyResults`,width:220,min:140},{key:`progress`,width:120,min:96},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Ae=[{key:`yearCycle`,label:`年度周期`},{key:`yearPlanId`,label:`年度计划`},{key:`quarter`,label:`季度周期`},{key:`keyResults`,label:`关键结果`},{key:`progress`,label:`完成度`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],je=`life.objectives.fields`,Me=`life.objectives.search`,Ne=`life.objectives.group`,Pe=[`yearQuarter`,`yearCycle`,`none`],Fe=[`Q1`,`Q2`,`Q3`,`Q4`,`unset`],P={Q1:`bg-[#e1eaff] text-[#1f4ec2]`,Q2:`bg-[#d9f5d2] text-[#1d7a12]`,Q3:`bg-[#fff1e3] text-[#a85b00]`,Q4:`bg-[#fee4e3] text-[#c02a26]`,unset:`bg-stone-300 text-stone-600`};function Ie(e){return e===`Q1`||e===`Q2`||e===`Q3`||e===`Q4`?e:`unset`}var F=T.filter(e=>e!==``).map(e=>({value:e,label:b[e]})),Le=[{value:`none`,label:`不分组`},{value:`yearQuarter`,label:`按年度 → 季度周期`},{value:`yearCycle`,label:`按年度周期分组`}];function I(e){return{title:``,yearCycle:e?.yearCycle??``,yearPlanId:e?.yearPlanId??``,quarter:e?.quarter??``}}function Re(e){return[...e].sort((e,t)=>(t.updatedAt||``).localeCompare(e.updatedAt||``)).map(e=>({value:e.id,label:e.title}))}function ze(e,t){return t?e.find(e=>e.id===t)?.title??``:``}function Be(e){let t={},n=/(?:^|\|)year:([^|]*)/.exec(e);n&&(t.yearCycle=n[1]??``);let r=/(?:^|\|)quarter:([^|]+)/.exec(e)?.[1];return r===`unset`||r===`other`?t.quarter=``:(r===`Q1`||r===`Q2`||r===`Q3`||r===`Q4`)&&(t.quarter=r),t}function Ve(e){for(let t of e)if(t.children?.length){let e=Ve(t.children);if(e)return e}else if(t.items!==void 0)return t.key;return`all`}function He(e){let{open:t,item:n,yearCycles:r,yearCycleMutate:o,yearPlans:s,isVisible:c,onClose:l,onSave:ee}=e,[u,d]=(0,M.useState)(I()),[f,p]=(0,M.useState)(!1),[m,h]=(0,M.useState)(``),te=(0,M.useMemo)(()=>Re(s),[s]);(0,M.useEffect)(()=>{t&&(h(``),p(!1),d({title:n.title,yearCycle:n.yearCycle,yearPlanId:n.yearPlanId||``,quarter:n.quarter}))},[t,n]);async function g(){let e=u.title.trim();if(!e)h(`请填写目标描述`);else{p(!0);try{await ee({...u,title:e,yearCycle:u.yearCycle,yearPlanId:u.yearPlanId},n.id),l()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}}function _(e){let t=s.find(t=>t.id===e);d({...u,yearPlanId:e,yearCycle:t?.yearCycle||u.yearCycle})}return(0,N.jsxs)(ve,{open:t,title:`目标详情`,onClose:l,footer:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{type:`button`,onClick:l,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,N.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>void g(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:f?`保存中…`:`保存`})]}),children:[m?(0,N.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:m}):null,(0,N.jsx)(k,{icon:(0,N.jsx)(O,{}),label:`目标描述`,children:(0,N.jsx)(`input`,{autoFocus:!0,value:u.title,onChange:e=>d({...u,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())},placeholder:`请输入内容`,className:A})}),c(`yearCycle`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`年度周期`,children:(0,N.jsx)(j,{flat:!0,className:`w-full`,yearCycles:r,value:u.yearCycle,onChange:e=>{let t=s.find(e=>e.id===u.yearPlanId),n=!!(u.yearPlanId&&t?.yearCycle&&t.yearCycle!==e);d({...u,yearCycle:e,...n?{yearPlanId:``}:null})},mutate:o,renderTrigger:(e,{empty:t})=>(0,N.jsx)(i,{text:e,className:`block min-w-0 flex-1 basis-0 truncate ${t?`text-stone-400`:`text-stone-800`}`})})}):null,c(`yearPlanId`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`年度计划`,children:(0,N.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索年度计划…`,ariaLabel:`年度计划`,options:te,value:u.yearPlanId,onChange:_,className:`w-full`,renderTrigger:()=>{let e=ze(s,u.yearPlanId);return(0,N.jsx)(i,{text:e||`未选择`,className:`block min-w-0 truncate ${e?`text-stone-800`:`text-stone-400`}`})}})}):null,c(`quarter`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`季度周期`,children:(0,N.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索季度周期…`,ariaLabel:`季度周期`,options:F,value:u.quarter,onChange:e=>d({...u,quarter:e}),className:`w-full`,renderTrigger:()=>(0,N.jsx)(i,{text:u.quarter?b[u.quarter]:S,className:`block min-w-0 truncate ${u.quarter?`text-stone-800`:`text-stone-400`}`})})}):null,c(`createdAt`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`创建日期`,children:(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.createdAt)})}):null,c(`updatedAt`)?(0,N.jsx)(k,{icon:(0,N.jsx)(D,{}),label:`修改日期`,children:(0,N.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.updatedAt)})}):null]})}function L(){let e=se(),{store:t,live:n,error:ve,setError:T,updateItem:D,createItems:O,deleteItems:k}=be(e.ready&&e.on),A=(0,M.useMemo)(()=>({createItems:O,updateItem:D,deleteItems:k}),[O,D,k]),I=me(je,Ae),[L,Ue]=he(Me),[R,We]=ie(Ne,Pe,`none`),[z,Ge]=(0,M.useState)({}),B=R===`yearQuarter`,Ke=de(B),qe=(0,M.useMemo)(()=>{let e=v(B);return ae(ke,I.isVisible).map(t=>t.key===`select`?{...t,width:e,min:e}:t)},[I.isVisible,B]),[V,H]=(0,M.useState)(null),[Je,Ye]=(0,M.useState)(null),[U,Xe]=(0,M.useState)(!1),[W,Ze]=(0,M.useState)(!1),[Qe,$e]=(0,M.useState)({}),[G,K]=(0,M.useState)(null),q=ee(`life.objectives.cols.v13`,qe),et=(0,M.useMemo)(()=>Re(t.yearPlans),[t.yearPlans]),tt=c(`life.objectives`),J=(0,M.useMemo)(()=>ne(Ce(t.objectives,L)),[t.objectives,L]),Y=(0,M.useMemo)(()=>{if(R===`none`)return[{key:`all`,label:`全部目标`,pill:`bg-stone-500 text-white`,items:J}];let e=e=>e.yearCycle.trim(),n=e=>e?Ee(t.yearCycles,e)||`未设置年度`:xe,r=[...new Set(J.map(e))];return r.sort((e,t)=>e?t?n(t).localeCompare(n(e),void 0,{numeric:!0}):-1:1),r.length===0?[{key:`year:`,label:xe,pill:h(``),items:[]}]:R===`yearCycle`?r.map(t=>{let r=J.filter(n=>e(n)===t),i=n(t);return{key:`year:${t}`,label:i,pill:h(t),items:r}}):r.map(t=>{let r=J.filter(n=>e(n)===t),i=n(t),a=Fe.map(e=>{let n=e===`unset`?S:b[e],i=r.filter(t=>(t.quarter||`unset`)===(e===`unset`?`unset`:e));return{key:`year:${t}|quarter:${e}`,label:n,pill:P[e],items:i}}),o=new Set(a.flatMap(e=>e.items.map(e=>e.id))),s=r.filter(e=>!o.has(e.id));return s.length>0&&a.push({key:`year:${t}|quarter:other`,label:`其它`,pill:P.unset,items:s}),{key:`year:${t}`,label:i,pill:h(t),children:a.filter(e=>e.items.length>0)}}).filter(e=>(e.children?.length??0)>0)},[R,J,t.yearCycles]),nt=(0,M.useMemo)(()=>ce(Y,R===`none`?{}:z),[Y,z,R]),rt=(0,M.useMemo)(()=>re(Y,R===`none`?{}:z),[Y,z,R]),X=p(rt),{submit:it}=pe({row:G,setRow:K,submitting:W,isPristine:e=>!e.title.trim()&&e.yearCycle===e.baseYearCycle&&e.yearPlanId===e.baseYearPlanId&&e.quarter===e.baseQuarter,onSubmit:async e=>{Ze(!0);try{await O(`objectives`,[{title:e.title,yearCycle:e.yearCycle,yearPlanId:e.yearPlanId,quarter:e.quarter}]),K(null),o(`已新增 Objective`,`success`),T(``)}catch(e){let t=e instanceof Error?e.message:String(e);T(t),o(`新增失败:${t}`,`error`)}finally{Ze(!1)}}});function at(e,t){let n=t?.yearCycle??``,r=t?.yearPlanId??``,i=t?.quarter??``;K({groupKey:e,title:``,yearCycle:n,yearPlanId:r,quarter:i,baseYearCycle:n,baseYearPlanId:r,baseQuarter:i}),Ge(t=>({...t,[e]:!1}))}function ot(e,n){return{yearPlanId:e,yearCycle:t.yearPlans.find(t=>t.id===e)?.yearCycle||n}}async function Z(e,t){try{await D(`objectives`,e,t),$e(t=>{let n={...t};return delete n[e],n}),T(``)}catch(e){let t=e instanceof Error?e.message:String(e);T(t),o(`保存失败:${t}`,`error`)}}function st(e){return{...e,...Qe[e.id]}}function ct(e,t){$e(n=>({...n,[e]:{...n[e],...t}}))}async function lt(e){let t=Qe[e.id];if(!t)return;let n=(t.title??e.title).trim();n?await Z(e.id,{...t,title:n}):T(`目标描述不能为空`)}async function ut(e,t){await D(`objectives`,t,e),o(`已保存`,`success`)}async function dt(){let e=V;if(e?.length){H(null),Xe(!0);try{await k(`objectives`,e.map(e=>e.id)),X.clear(),o(e.length>1?`已删除 ${e.length} 条`:`已删除`,`success`)}catch(e){T(e instanceof Error?e.message:String(e))}finally{Xe(!1)}}}function Q(){return G?(0,N.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,N.jsx)(`td`,{className:u,style:Ke,children:(0,N.jsx)(`input`,{autoFocus:!0,disabled:W,value:G.title,placeholder:`输入目标名称,回车或点空白处保存`,onChange:e=>K(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),it()):e.key===`Escape`&&(e.preventDefault(),K(null))},className:ye})}),I.isVisible(`yearCycle`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(j,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:G.yearCycle,onChange:e=>K(n=>{if(!n)return n;let r=t.yearPlans.find(e=>e.id===n.yearPlanId),i=!!(n.yearPlanId&&r?.yearCycle&&r.yearCycle!==e);return{...n,yearCycle:e,...i?{yearPlanId:``}:null}}),mutate:A})}):null,I.isVisible(`yearPlanId`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索年度计划…`,ariaLabel:`年度计划`,options:et,value:G.yearPlanId,onChange:e=>K(t=>t&&{...t,...ot(e,t.yearCycle)}),triggerClassName:G.yearPlanId?w:C,renderTrigger:()=>{let e=ze(t.yearPlans,G.yearPlanId);return e?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md bg-[#e8f0fe] px-2 text-xs font-medium text-[#1f4ec2]`,children:(0,N.jsx)(i,{text:e,className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,I.isVisible(`quarter`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索季度周期…`,ariaLabel:`季度周期`,options:F,value:G.quarter,onChange:e=>K(t=>t&&{...t,quarter:e}),triggerClassName:G.quarter?w:C,renderTrigger:()=>G.quarter?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${P[Ie(G.quarter)]}`,children:(0,N.jsx)(i,{text:b[G.quarter],className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})})}):null,I.isVisible(`keyResults`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-400`,children:`—`}):null,I.isVisible(`progress`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,N.jsx)(g,{value:0})}):null,I.isVisible(`createdAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:`—`,muted:!0})}):null,I.isVisible(`updatedAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:`—`,muted:!0})}):null,(0,N.jsx)(`td`,{"aria-hidden":`true`}),(0,N.jsx)(`td`,{className:l})]}):null}function ft(e,n,r=0){let o=st(e),s=_e(o.id,t.krTasks),c=we(o.id,t.krTasks,t.krTodos);return(0,N.jsxs)(`tr`,{className:`group/row tw-life-group-body hover:bg-[#f7f8fa]`,children:[(0,N.jsx)(Se,{checked:!!X.selected[e.id],onChange:()=>X.toggle(e.id),label:`选择 ${e.title}`,index:n,selecting:X.selectedIds.length>0,depth:r}),(0,N.jsx)(`td`,{className:u,style:Ke,children:(0,N.jsx)(oe,{value:o.title,placeholder:`目标描述`,onChange:t=>ct(e.id,{title:t}),onCommit:()=>void lt(e),onCancel:()=>$e(t=>{let n={...t};return delete n[e.id],n})})}),I.isVisible(`yearCycle`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(j,{unstyled:!0,pill:!0,yearCycles:t.yearCycles,value:o.yearCycle,onChange:n=>{let r=t.yearPlans.find(e=>e.id===o.yearPlanId),i=o.yearPlanId&&r?.yearCycle&&r.yearCycle!==n?{yearCycle:n,yearPlanId:``}:{yearCycle:n};Qe[e.id]?ct(e.id,i):Z(e.id,i)},mutate:A})}):null,I.isVisible(`yearPlanId`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索年度计划…`,ariaLabel:`年度计划`,options:et,value:o.yearPlanId||``,onChange:t=>{let n=ot(t,o.yearCycle);Z(e.id,n)},triggerClassName:o.yearPlanId?w:C,renderTrigger:()=>{let e=ze(t.yearPlans,o.yearPlanId||``);return e?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md bg-[#e8f0fe] px-2 text-xs font-medium text-[#1f4ec2]`,children:(0,N.jsx)(i,{text:e,className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})}})}):null,I.isVisible(`quarter`)?(0,N.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,N.jsx)(a,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索季度周期…`,ariaLabel:`季度周期`,options:F,value:o.quarter,onChange:t=>void Z(e.id,{quarter:t}),triggerClassName:o.quarter?w:C,renderTrigger:()=>o.quarter?(0,N.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${P[Ie(o.quarter)]}`,children:(0,N.jsx)(i,{text:b[o.quarter],className:`block min-w-0 truncate`})}):(0,N.jsx)(i,{text:S,className:`block min-w-0 truncate text-stone-400`})})}):null,I.isVisible(`keyResults`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,N.jsx)(i,{text:s.length?s.join(` · `):`暂无 KR 任务`,className:`block min-w-0 truncate text-xs text-stone-600`})}):null,I.isVisible(`progress`)?(0,N.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:(0,N.jsx)(g,{value:c})}):null,I.isVisible(`createdAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:E(e.createdAt),muted:!e.createdAt})}):null,I.isVisible(`updatedAt`)?(0,N.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,N.jsx)(y,{text:E(e.updatedAt),muted:!e.updatedAt})}):null,(0,N.jsx)(`td`,{"aria-hidden":`true`}),(0,N.jsx)(`td`,{className:l,children:(0,N.jsxs)(`div`,{className:`flex justify-end gap-0.5`,children:[(0,N.jsx)(le,{label:`编辑 ${e.title}`,disabled:U,onClick:()=>Ye(e)}),(0,N.jsx)(Oe,{label:`删除 ${e.title}`,disabled:U,onClick:()=>H([e])})]})})]},e.id)}if(!e.ready)return(0,N.jsx)(ue,{label:`正在读取插件开关`});if(!e.on)return(0,N.jsx)(_,{children:fe()});if(n===null)return(0,N.jsx)(ue,{label:`正在连接人生管理服务`});if(!n)return(0,N.jsx)(_,{children:`人生管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`});let $=qe.length;return(0,N.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,N.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,N.jsx)(`span`,{className:`font-medium text-stone-800`,children:t.objectives.length}),` 条`]}),(0,N.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`input`,{value:L,onChange:e=>Ue(e.target.value),placeholder:`搜索 Objective…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,N.jsx)(a,{flat:!0,className:`w-[148px]`,ariaLabel:`分组方式`,options:Le,value:R,onChange:e=>We(e)}),(0,N.jsx)(te,{fields:I.fields,isVisible:I.isVisible,onToggle:I.toggle}),(0,N.jsx)(`button`,{type:`button`,disabled:U||X.selectedIds.length===0,onClick:()=>H(t.objectives.filter(e=>X.selected[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,N.jsx)(`button`,{type:`button`,disabled:U||W,onClick:()=>{let e=Ve(Y);at(e,Be(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:`+ 新建目标`})]})]}),(0,N.jsx)(De,{error:ve,onDismiss:()=>T(``)}),(0,N.jsx)(`div`,{ref:tt,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,N.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,N.jsx)(`colgroup`,{children:qe.map(e=>(0,N.jsx)(`col`,{style:e.key===`select`?{width:v(B)}:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,N.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,N.jsxs)(`tr`,{children:[(0,N.jsx)(m,{checked:X.allVisibleSelected,indeterminate:X.selectedIds.length>0&&!X.allVisibleSelected,onChange:()=>X.toggleAllVisible(),nested:B}),(0,N.jsxs)(`th`,{className:`${d} text-xs text-stone-500`,style:Ke,children:[`目标描述`,(0,N.jsx)(f,{...q.resizeProps(`title`)})]}),I.isVisible(`yearCycle`)?(0,N.jsxs)(`th`,{className:x,children:[`年度周期`,(0,N.jsx)(f,{...q.resizeProps(`yearCycle`)})]}):null,I.isVisible(`yearPlanId`)?(0,N.jsxs)(`th`,{className:x,children:[`年度计划`,(0,N.jsx)(f,{...q.resizeProps(`yearPlanId`)})]}):null,I.isVisible(`quarter`)?(0,N.jsxs)(`th`,{className:x,children:[`季度周期`,(0,N.jsx)(f,{...q.resizeProps(`quarter`)})]}):null,I.isVisible(`keyResults`)?(0,N.jsxs)(`th`,{className:x,children:[`关键结果(KR 任务)`,(0,N.jsx)(f,{...q.resizeProps(`keyResults`)})]}):null,I.isVisible(`progress`)?(0,N.jsxs)(`th`,{className:x,children:[`完成度`,(0,N.jsx)(f,{...q.resizeProps(`progress`)})]}):null,I.isVisible(`createdAt`)?(0,N.jsxs)(`th`,{className:x,children:[`创建日期`,(0,N.jsx)(f,{...q.resizeProps(`createdAt`)})]}):null,I.isVisible(`updatedAt`)?(0,N.jsxs)(`th`,{className:x,children:[`修改日期`,(0,N.jsx)(f,{...q.resizeProps(`updatedAt`)})]}):null,(0,N.jsx)(`th`,{"aria-hidden":`true`}),(0,N.jsx)(`th`,{className:s,children:`操作`})]})}),(0,N.jsx)(`tbody`,{children:J.length===0&&!G?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:$,className:`px-3 py-16 text-center text-sm text-stone-400`,children:t.objectives.length===0?`还没有 Objective`:`没有匹配的记录`})}):J.length===0&&G?Q():R===`none`?(0,N.jsxs)(N.Fragment,{children:[J.map((e,t)=>ft(e,t+1)),G?Q():(0,N.jsx)(ge,{colSpan:$,depth:0,selectColPx:v(B),disabled:U||W,onClick:()=>at(`all`)})]}):nt.length===0?G?Q():null:nt.map(e=>{let t=!z[e.key];return(0,N.jsxs)(M.Fragment,{children:[(0,N.jsx)(Te,{label:e.label,pill:e.pill,count:e.count,open:t,depth:e.depth,kind:e.kind,colSpan:$,selectColPx:v(B),onToggle:()=>Ge(t=>({...t,[e.key]:!t[e.key]}))}),e.items?.map((t,n)=>ft(t,n+1,e.depth)),e.items&&e.items.length>0?G?.groupKey===e.key?Q():(0,N.jsx)(ge,{colSpan:$,depth:e.depth,selectColPx:v(B),disabled:U||W,onClick:()=>at(e.key,Be(e.key))}):G?.groupKey===e.key?Q():null]},e.key)})})]})}),(0,N.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,N.jsxs)(`span`,{children:[`显示 `,J.length,` 条`,X.selectedIds.length?` · 已选 ${X.selectedIds.length}`:``]}),(0,N.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`选「年度计划」后,对应计划的关联 Objective 会自动带出`})]}),Je?(0,N.jsx)(He,{open:!0,item:Je,yearCycles:t.yearCycles,yearCycleMutate:A,yearPlans:t.yearPlans,isVisible:I.isVisible,onClose:()=>Ye(null),onSave:ut}):null,(0,N.jsx)(r,{open:V!=null,title:V&&V.length>1?`批量删除`:`删除 Objective`,message:V&&V.length>1?`删除选中的 ${V.length} 条目标?`:`删除「${V?.[0]?.title??``}」?`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>H(null),onConfirm:()=>void dt()})]})}export{L as default};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.TgxIOKMD.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{t as s}from"./NamePromptDialog.Csfnh5eM.js";import{m as c}from"./PmShared.BJpoEYvk.js";import{B as l,h as u,xt as d,yt as f}from"./LifeShared.Di9sdb_T.js";var p=e(t(),1),m=n(),h=u;function g(e){let{planTypes:t,value:n,onChange:u,mutate:g,flat:_,unstyled:v,pill:y,className:b,triggerClassName:x,ariaLabel:S=`计划类型`,searchPlaceholder:C=`搜索类型…`,placeholder:w=h,renderTrigger:T}=e,[E,D]=(0,p.useState)(!1),[O,k]=(0,p.useState)(null),[A,j]=(0,p.useState)(``),[M,N]=(0,p.useState)(null),P=(0,p.useMemo)(()=>d(t),[t]),F=(0,p.useMemo)(()=>P.map(e=>({value:e.id,label:e.name})),[P]),I=n&&F.some(e=>e.value===n)?n:``,L=!I,R=L?w:f(P,I);async function z(e){let t=e.trim();if(!t)return;let n=P.find(e=>e.name===t);if(n)u(n.id);else{D(!0);try{let e=(await g.createItems(`planTypes`,[{name:t}])).items[0];e?.id&&u(e.id),o(`已新增「${t}」`,`success`)}catch(e){o(e instanceof Error?e.message:String(e),`error`)}finally{D(!1)}}}async function B(e){let t=O;if(!t)return;let n=e.trim();if(!n||n===t.name)k(null),j(``);else{D(!0),j(``);try{await g.updateItem(`planTypes`,t.id,{name:n}),k(null),o(`已修改类型名称`,`success`)}catch(e){j(e instanceof Error?e.message:String(e))}finally{D(!1)}}}async function V(){let e=M;if(e){N(null),D(!0);try{await g.deleteItems(`planTypes`,[e.id]),I===e.id&&u(``),o(`已删除类型`,`success`)}catch(e){o(e instanceof Error?e.message:String(e),`error`)}finally{D(!1)}}}return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(a,{flat:_,unstyled:v,centerContent:!1,className:b,triggerClassName:(y?L?`h-8 w-full justify-start rounded-md border border-stone-200 bg-white px-2 text-left text-sm font-normal text-stone-400 hover:border-stone-300 focus:ring-2 focus:ring-[#3370ff]/30`:`h-8 w-full justify-start bg-transparent px-0 text-left focus:ring-0`:void 0)??x,searchable:!0,searchPlaceholder:C,ariaLabel:S,options:F,value:I,onChange:u,onSearchCreate:e=>void z(e),renderTrigger:T?(e,t)=>T(R,{...t,empty:L}):()=>y&&!L?(0,m.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${l(I)}`,children:(0,m.jsx)(i,{text:R,className:`block min-w-0 truncate`})}):(0,m.jsx)(i,{text:R,className:`block min-w-0 truncate ${L||F.length===0?`text-stone-400`:`text-stone-800`}`}),renderOptionAction:e=>(0,m.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,m.jsx)(`button`,{type:`button`,disabled:E,"aria-label":`修改 ${e.label}`,className:`rounded p-1 text-stone-400 opacity-0 transition-opacity hover:bg-stone-100 hover:text-stone-700 focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-0`,onClick:()=>{let t=P.find(t=>t.id===e.value);t&&(j(``),k(t))},children:(0,m.jsx)(c,{name:`pencil`,size:13})}),(0,m.jsx)(`button`,{type:`button`,disabled:E,"aria-label":`删除 ${e.label}`,className:`tw-icon-danger rounded p-1 opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-0 disabled:group-hover:opacity-40`,onClick:()=>{let t=P.find(t=>t.id===e.value);t&&N(t)},children:(0,m.jsx)(c,{name:`trash`,size:13})})]})}),(0,m.jsx)(s,{open:O!=null,title:`修改计划类型`,label:`类型名称`,placeholder:`请输入类型名称`,initialValue:O?.name??``,confirmLabel:`保存`,cancelLabel:`取消`,error:A,onClose:()=>{k(null),j(``)},onConfirm:e=>void B(e)}),(0,m.jsx)(r,{open:M!=null,title:`删除计划类型`,message:`删除「${M?.name??``}」?已引用该类型的记录会清空类型。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>N(null),onConfirm:()=>void V()})]})}export{g as t};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.TgxIOKMD.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{t as s}from"./NamePromptDialog.Csfnh5eM.js";import{m as c}from"./PmShared.BJpoEYvk.js";import{B as l,h as u,xt as d,yt as f}from"./LifeShared.SnLIiFdN.js";var p=e(t(),1),m=n(),h=u;function g(e){let{planTypes:t,value:n,onChange:u,mutate:g,flat:_,unstyled:v,pill:y,className:b,triggerClassName:x,ariaLabel:S=`计划类型`,searchPlaceholder:C=`搜索类型…`,placeholder:w=h,renderTrigger:T}=e,[E,D]=(0,p.useState)(!1),[O,k]=(0,p.useState)(null),[A,j]=(0,p.useState)(``),[M,N]=(0,p.useState)(null),P=(0,p.useMemo)(()=>d(t),[t]),F=(0,p.useMemo)(()=>P.map(e=>({value:e.id,label:e.name})),[P]),I=n&&F.some(e=>e.value===n)?n:``,L=!I,R=L?w:f(P,I);async function z(e){let t=e.trim();if(!t)return;let n=P.find(e=>e.name===t);if(n)u(n.id);else{D(!0);try{let e=(await g.createItems(`planTypes`,[{name:t}])).items[0];e?.id&&u(e.id),o(`已新增「${t}」`,`success`)}catch(e){o(e instanceof Error?e.message:String(e),`error`)}finally{D(!1)}}}async function B(e){let t=O;if(!t)return;let n=e.trim();if(!n||n===t.name)k(null),j(``);else{D(!0),j(``);try{await g.updateItem(`planTypes`,t.id,{name:n}),k(null),o(`已修改类型名称`,`success`)}catch(e){j(e instanceof Error?e.message:String(e))}finally{D(!1)}}}async function V(){let e=M;if(e){N(null),D(!0);try{await g.deleteItems(`planTypes`,[e.id]),I===e.id&&u(``),o(`已删除类型`,`success`)}catch(e){o(e instanceof Error?e.message:String(e),`error`)}finally{D(!1)}}}return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(a,{flat:_,unstyled:v,centerContent:!1,className:b,triggerClassName:(y?L?`h-8 w-full justify-start rounded-md border border-stone-200 bg-white px-2 text-left text-sm font-normal text-stone-400 hover:border-stone-300 focus:ring-2 focus:ring-[#3370ff]/30`:`h-8 w-full justify-start bg-transparent px-0 text-left focus:ring-0`:void 0)??x,searchable:!0,searchPlaceholder:C,ariaLabel:S,options:F,value:I,onChange:u,onSearchCreate:e=>void z(e),renderTrigger:T?(e,t)=>T(R,{...t,empty:L}):()=>y&&!L?(0,m.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${l(I)}`,children:(0,m.jsx)(i,{text:R,className:`block min-w-0 truncate`})}):(0,m.jsx)(i,{text:R,className:`block min-w-0 truncate ${L||F.length===0?`text-stone-400`:`text-stone-800`}`}),renderOptionAction:e=>(0,m.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,m.jsx)(`button`,{type:`button`,disabled:E,"aria-label":`修改 ${e.label}`,className:`rounded p-1 text-stone-400 opacity-0 transition-opacity hover:bg-stone-100 hover:text-stone-700 focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-0`,onClick:()=>{let t=P.find(t=>t.id===e.value);t&&(j(``),k(t))},children:(0,m.jsx)(c,{name:`pencil`,size:13})}),(0,m.jsx)(`button`,{type:`button`,disabled:E,"aria-label":`删除 ${e.label}`,className:`tw-icon-danger rounded p-1 opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100 disabled:opacity-0 disabled:group-hover:opacity-40`,onClick:()=>{let t=P.find(t=>t.id===e.value);t&&N(t)},children:(0,m.jsx)(c,{name:`trash`,size:13})})]})}),(0,m.jsx)(s,{open:O!=null,title:`修改计划类型`,label:`类型名称`,placeholder:`请输入类型名称`,initialValue:O?.name??``,confirmLabel:`保存`,cancelLabel:`取消`,error:A,onClose:()=>{k(null),j(``)},onConfirm:e=>void B(e)}),(0,m.jsx)(r,{open:M!=null,title:`删除计划类型`,message:`删除「${M?.name??``}」?已引用该类型的记录会清空类型。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>N(null),onConfirm:()=>void V()})]})}export{g as t};
@@ -1,4 +1,4 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.TgxIOKMD.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{c as s,d as c,i as l,l as u,n as d,o as ee,t as f}from"./ColumnResize.CkE59sGq.js";import{$ as p,A as m,B as h,C as te,D as g,E as ne,G as re,H as ie,J as ae,L as oe,M as _,N as se,Q as ce,S as le,T as ue,U as de,V as fe,W as v,X as pe,Y as me,Z as he,_ as ge,b as _e,c as ve,ct as y,et as ye,f as b,g as x,k as be,lt as S,m as C,o as w,pt as xe,q as Se,v as Ce,vt as T,w as we,wt as Te,x as Ee,y as De,z as E}from"./LifeShared.Di9sdb_T.js";import{c as D,l as O,n as k,t as A}from"./DrawerField.CiHAvXHQ.js";var j=e(t(),1),M=n(),Oe=[{key:`select`,width:36,min:32},{key:`title`,width:200,min:140},{key:`objective`,width:180,min:120},{key:`year`,width:88,min:72},{key:`quarter`,width:120,min:88},{key:`progress`,width:120,min:96},{key:`score`,width:72,min:56},{key:`experience`,width:220,min:140},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],ke=[{key:`objective`,label:`Objective`},{key:`year`,label:`年度周期`},{key:`quarter`,label:`季度周期`},{key:`progress`,label:`完成度`},{key:`score`,label:`评分`},{key:`experience`,label:`经验收获`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Ae=`life.reviews.fields`,je=`life.reviews.search`,Me=`life.reviews.group`,Ne=[`year`,`none`],Pe=[{value:`none`,label:`不分组`},{value:`year`,label:`按年度周期分组`}];function Fe(e){return{title:``,objectiveId:e?.objectiveId??``,score:e?.score??0,experience:e?.experience??`1) 有什么是做得好的
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";import{t as r}from"./ConfirmDialog.D5qXeML0.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.TgxIOKMD.js";import{showToast as o}from"./Toast.BO2NFckG.js";import{c as s,d as c,i as l,l as u,n as d,o as ee,t as f}from"./ColumnResize.CkE59sGq.js";import{$ as p,A as m,B as h,C as te,D as g,E as ne,G as re,H as ie,J as ae,L as oe,M as _,N as se,Q as ce,S as le,T as ue,U as de,V as fe,W as v,X as pe,Y as me,Z as he,_ as ge,b as _e,c as ve,ct as y,et as ye,f as b,g as x,k as be,lt as S,m as C,o as w,pt as xe,q as Se,v as Ce,vt as T,w as we,wt as Te,x as Ee,y as De,z as E}from"./LifeShared.SnLIiFdN.js";import{c as D,l as O,n as k,t as A}from"./DrawerField.CiHAvXHQ.js";var j=e(t(),1),M=n(),Oe=[{key:`select`,width:36,min:32},{key:`title`,width:200,min:140},{key:`objective`,width:180,min:120},{key:`year`,width:88,min:72},{key:`quarter`,width:120,min:88},{key:`progress`,width:120,min:96},{key:`score`,width:72,min:56},{key:`experience`,width:220,min:140},{key:`createdAt`,width:120,min:96},{key:`updatedAt`,width:120,min:96},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],ke=[{key:`objective`,label:`Objective`},{key:`year`,label:`年度周期`},{key:`quarter`,label:`季度周期`},{key:`progress`,label:`完成度`},{key:`score`,label:`评分`},{key:`experience`,label:`经验收获`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Ae=`life.reviews.fields`,je=`life.reviews.search`,Me=`life.reviews.group`,Ne=[`year`,`none`],Pe=[{value:`none`,label:`不分组`},{value:`year`,label:`按年度周期分组`}];function Fe(e){return{title:``,objectiveId:e?.objectiveId??``,score:e?.score??0,experience:e?.experience??`1) 有什么是做得好的
2
2
  2) 有什么是做得不够好的
3
3
  3) 总结如何下次做得更好`}}function N(e,t,n){if(e.trim()||!t)return;let r=n.find(e=>e.id===t)?.title.trim();return r?`${r} 复盘`:void 0}function P(e){return Math.max(0,Math.min(100,Number.isFinite(e)?e:0))}function Ie(e,t){let n=t?.yearCycle?.trim()||``;return n&&Te(e.yearCycles,n)||`—`}function Le(e){let{open:t,item:n,objectiveOptions:r,store:o,isVisible:s,onClose:c,onSave:l}=e,[u,d]=(0,j.useState)(Fe()),[ee,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(``);(0,j.useEffect)(()=>{t&&(m(``),f(!1),d({title:n.title,objectiveId:n.objectiveId,score:n.score,experience:n.experience}))},[t,n]);let h=v(o,u.objectiveId),te=h?T(h.id,o.krTasks,o.krTodos):0;async function g(){let e=u.title.trim();if(!e)m(`请填写复盘标题`);else{f(!0);try{await l({...u,title:e,score:P(u.score)},n.id),c()}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(!1)}}}return(0,M.jsxs)(_e,{open:t,title:`复盘详情`,onClose:c,footer:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,onClick:c,className:`h-9 rounded-lg border border-stone-200 px-4 text-sm text-stone-700 hover:bg-stone-50`,children:`取消`}),(0,M.jsx)(`button`,{type:`button`,disabled:ee,onClick:()=>void g(),className:`h-9 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:ee?`保存中…`:`保存`})]}),children:[p?(0,M.jsx)(`p`,{className:`mx-6 mb-2 text-sm text-red-600`,children:p}):null,(0,M.jsx)(k,{icon:(0,M.jsx)(O,{}),label:`标题`,children:(0,M.jsx)(`input`,{autoFocus:!0,value:u.title,onChange:e=>d({...u,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())},placeholder:`请输入内容`,className:A})}),s(`objective`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`Objective`,children:(0,M.jsx)(a,{flat:!0,searchable:!0,searchPlaceholder:`搜索 Objective…`,ariaLabel:`Objective`,options:r,value:u.objectiveId,onChange:e=>{let t=N(u.title,e,o.objectives);d({...u,objectiveId:e,...t?{title:t}:null})},className:`w-full`,triggerClassName:u.objectiveId?void 0:w,renderTrigger:()=>u.objectiveId&&h?(0,M.jsx)(i,{text:h.title,className:`block min-w-0 truncate text-stone-800`}):(0,M.jsx)(i,{text:C,className:`block min-w-0 truncate text-stone-400`})})}):null,s(`year`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`年度周期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:h?Ie(o,h):`跟随所属目标`})}):null,s(`quarter`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`季度周期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:h?h.quarter?y[h.quarter]:`—`:`跟随所属目标`})}):null,s(`progress`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`完成度`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:h?`${te}%(按关联 KR 任务完成度)`:`关联 Objective 后自动计算`})}):null,s(`score`)?(0,M.jsx)(k,{icon:(0,M.jsx)(O,{}),label:`评分`,children:(0,M.jsx)(`input`,{type:`number`,min:0,max:100,value:u.score,onChange:e=>{let t=e.target.value;if(t===``){d({...u,score:0});return}let n=Number(t);Number.isFinite(n)&&d({...u,score:P(n)})},className:A})}):null,s(`experience`)?(0,M.jsx)(k,{icon:(0,M.jsx)(O,{}),label:`经验收获`,children:(0,M.jsx)(`textarea`,{value:u.experience,onChange:e=>d({...u,experience:e.target.value}),placeholder:S,rows:4,className:`w-full rounded-md border border-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`})}):null,s(`createdAt`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`创建日期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.createdAt)})}):null,s(`updatedAt`)?(0,M.jsx)(k,{icon:(0,M.jsx)(D,{}),label:`修改日期`,children:(0,M.jsx)(`div`,{className:`px-2 py-1.5 text-sm text-stone-500`,children:E(n.updatedAt)})}):null]})}function F(){let e=ce(),{store:t,live:n,error:_e,setError:S,updateItem:D,createItems:O,deleteItems:k}=ye(e.ready&&e.on),[A,Fe]=he(je),F=de(),[I,Re]=ae(Me,Ne,`none`),[ze,Be]=(0,j.useState)({}),[L,R]=(0,j.useState)(null),[Ve,He]=(0,j.useState)(null),[z,Ue]=(0,j.useState)(!1),[B,We]=(0,j.useState)(!1),[V,H]=(0,j.useState)({}),[U,W]=(0,j.useState)(null),G=me(Ae,ke),Ge=(0,j.useMemo)(()=>oe(Oe,G.isVisible),[G.isVisible]),K=u(`life.reviews.cols.v12`,Ge),Ke=c(`life.reviews`),qe=(0,j.useMemo)(()=>[{value:``,label:C},...Se(t.objectives).map(e=>({value:e.id,label:e.title}))],[t.objectives]),q=(0,j.useMemo)(()=>re(xe(t.reviews,A)),[t.reviews,A]),J=(0,j.useMemo)(()=>{if(I===`none`)return[{key:`all`,label:`全部复盘`,pill:`bg-stone-500 text-white`,items:q}];let e=e=>v(t,e.objectiveId)?.yearCycle?.trim()||``,n=e=>e?Te(t.yearCycles,e)||e:x,r=[...new Set(q.map(e))];r.sort((e,t)=>e?t?n(t).localeCompare(n(e),void 0,{numeric:!0}):-1:1);let i=r.filter(Boolean).map(t=>({key:`year:${t}`,label:n(t),pill:h(t),items:q.filter(n=>e(n)===t)})),a=q.filter(e=>!v(t,e.objectiveId)?.yearCycle?.trim());return a.length&&i.push({key:`year:unset`,label:x,pill:h(``),items:a}),i},[I,q,t,t.yearCycles]),Y=(0,j.useMemo)(()=>{if(I===`none`)return J;let e=J.filter(e=>e.items.length>0);return e.length>0?e:[{key:`year:unset`,label:x,pill:h(``),items:[]}]},[I,J]),Je=(0,j.useMemo)(()=>Y.flatMap(e=>e.items.map(e=>e.id)),[Y]),X=p(Je),{submit:Ye}=pe({row:U,setRow:W,submitting:B,isPristine:e=>!e.title.trim()&&e.objectiveId===e.baseObjectiveId&&e.score===e.baseScore&&e.experience===e.baseExperience,onSubmit:async e=>{We(!0);try{await O(`reviews`,[{title:e.title,objectiveId:e.objectiveId,score:P(e.score),experience:e.experience}]),W(null),o(`已新增复盘`,`success`),S(``)}catch(e){let t=e instanceof Error?e.message:String(e);S(t),o(`新增失败:${t}`,`error`)}finally{We(!1)}}});function Xe(e,t){let n=t?.objectiveId??``,r=t?.score??0,i=t?.experience??`1) 有什么是做得好的
4
4
  2) 有什么是做得不够好的
@@ -0,0 +1,3 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.C4rpn1Ix.js";import{i as r,o as i,s as a}from"./plugins.C0NrHGZv.js";import{a as o,n as s,o as c,r as l,s as u,t as d}from"./view-prefs.8MPl3A7e.js";import{i as f,n as p,r as ee,t as m}from"./dialog.DZHZCe_T.js";import{t as h}from"./jsx-runtime.DUg_B_vD.js";import{t as te}from"./DatePicker.Bkl71M49.js";import{t as g}from"./OverflowHint.pvo2Xc8R.js";var _=e(t(),1),v=`/__tb_life`,ne=[`pending`,`in_progress`,`overdue`,`stalled`,`done`,`closed`],y=[`pool`,`in_progress`,`incomplete`,`done`,`closed`],b=[`in_progress`,`incomplete`,`done`],re=[`urgent_important`,`urgent`,`important`,`normal`],ie={learning:`pt_learning`,work:`pt_work`,family:`pt_family`,side:`pt_side`},ae=[`Q1`,`Q2`,`Q3`,`Q4`],x={pending:`待开始`,in_progress:`进行中`,overdue:`已延期`,done:`已完成`,stalled:`已停滞`,closed:`已关闭`},oe={pool:`任务池`,in_progress:`进行中`,done:`已完成`,incomplete:`未完成`,closed:`已关闭`},se={in_progress:`进行中`,incomplete:`未完成`,done:`已完成`},ce={urgent_important:`重要紧急`,urgent:`紧急不重要`,important:`重要不紧急`,normal:`不重要不紧急`,"":`—`},le={learning:`学习成长`,work:`工作管理`,family:`家庭生活`,side:`副业赚钱`,pt_learning:`学习成长`,pt_work:`工作管理`,pt_family:`家庭生活`,pt_side:`副业赚钱`,"":`—`};function ue(e){return[...e].sort((e,t)=>{let n=(t.updatedAt||``).localeCompare(e.updatedAt||``);return n===0?e.name.localeCompare(t.name,`zh`):n})}function de(e){return[...e].sort((e,t)=>{let n=(t.updatedAt||``).localeCompare(e.updatedAt||``);return n===0?e.name.localeCompare(t.name,`zh`):n})}function S(e){return[...e].sort((e,t)=>{let n=(t.updatedAt||``).localeCompare(e.updatedAt||``);return n===0?e.name.localeCompare(t.name,`zh`):n})}function C(e,t){if(!t)return``;let n=e.find(e=>e.id===t);return n?n.name:le[t]||t}function w(e,t){if(!t)return``;let n=e.find(e=>e.id===t);return n?n.name:t}function T(e,t){if(!t)return``;let n=e.find(e=>e.id===t);return n?n.name:t}function E(e,t){let n=M(e,40);return n?t.some(e=>e.id===n)?n:t.find(e=>e.name===n)?.id??``:``}function D(e,t){let n=M(e,60);return n?t.some(e=>e.id===n)?n:t.find(e=>e.name===n)?.id??``:``}function O(e,t){let n=M(e,64);if(!n)return``;if(t.has(n))return n;let r=ie[n];return r&&t.has(r)?r:``}var k=`1) 有什么是做得好的
2
+ 2) 有什么是做得不够好的
3
+ 3) 总结如何下次做得更好`,A={Q1:`Q1(1月-3月)`,Q2:`Q2(4月-6月)`,Q3:`Q3(7月-9月)`,Q4:`Q4(10月-12月)`,"":`—`},j=/^\d{4}-\d{2}-\d{2}$/;function M(e,t=2e3){return typeof e==`string`?e.trim().slice(0,t):``}function N(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function P(e,t){if(!j.test(e)||!j.test(t))return null;let n=Date.parse(`${e}T00:00:00`),r=Date.parse(`${t}T00:00:00`);return!Number.isFinite(n)||!Number.isFinite(r)?null:Math.max(1,Math.round((r-n)/864e5)+1)}function F(e){return e==null?`—`:`${e} 天`}function I(){return{krTodos:[],krTasks:[],objectives:[],reviews:[],yearPlans:[],lifeStages:[],planTypes:[],yearCycles:[],lifeCycles:[]}}function L(e){return Array.isArray(e)?e:[]}function R(e){if(!e||typeof e!=`object`)return null;let t=e,n=M(t.name,40),r=M(t.id,64);return!n||!r?null:{id:r,name:n,createdAt:M(t.createdAt,40),updatedAt:M(t.updatedAt,40)}}function z(e){if(!e||typeof e!=`object`)return null;let t=e,n=M(t.name,40),r=M(t.id,64);return!n||!r?null:{id:r,name:n,createdAt:M(t.createdAt,40),updatedAt:M(t.updatedAt,40)}}function B(e){if(!e||typeof e!=`object`)return null;let t=e,n=M(t.name,60),r=M(t.id,64);return!n||!r?null:{id:r,name:n,createdAt:M(t.createdAt,40),updatedAt:M(t.updatedAt,40)}}function V(e){if(!e||typeof e!=`object`)return I();let t=e,n=L(t.planTypes).map(R).filter(e=>!!e),r=new Set(n.map(e=>e.id)),i=L(t.yearCycles).map(z).filter(e=>!!e),a=L(t.lifeCycles).map(B).filter(e=>!!e),o=e=>({...e,planType:O(e.planType,r)}),s=e=>({...e,yearCycle:E(e.yearCycle,i)}),c=e=>{let t=e.lifeCycle||e.ageRange,{ageRange:n,...r}=e;return{...r,lifeCycle:D(t,a)}},l=L(t.yearPlans).map(o).map(s),u=new Set(l.map(e=>e.id)),d=L(t.objectives).map(s).map(e=>{let t=M(e.yearPlanId,64);return{...e,yearPlanId:t&&u.has(t)?t:``}});return{krTodos:L(t.krTodos),krTasks:L(t.krTasks).map(o),objectives:d,reviews:L(t.reviews),yearPlans:l,lifeStages:L(t.lifeStages).map(o).map(c),planTypes:n,yearCycles:i,lifeCycles:a}}async function H(){let e=await fetch(v,{headers:{Accept:`application/json`}}),t=await e.json().catch(()=>({}));if(!e.ok||!t?.ok)throw Error(M(t?.error)||`读取失败(${e.status})`);return V(t)}async function fe(){let e=await(await fetch(`${v}?health=1`,{headers:{Accept:`application/json`}})).json().catch(()=>({}));return{ok:!!e?.ok,files:e?.files}}async function pe(e,t){let n=await fetch(v,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({entity:e,items:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!r?.ok)throw Error(M(r?.error)||`创建失败(${n.status})`);return{items:L(r.items),total:Number(r.total)||0}}async function me(e,t,n){let r=await fetch(v,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({entity:e,id:t,...n})}),i=await r.json().catch(()=>({}));if(!r.ok||!i?.ok)throw Error(M(i?.error)||`更新失败(${r.status})`);return i.item}async function he(e,t){let n=await fetch(v,{method:`DELETE`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({entity:e,ids:t})}),r=await n.json().catch(()=>({}));if(!n.ok||!r?.ok)throw Error(M(r?.error)||`删除失败(${n.status})`);return{removed:Number(r.removed)||0,total:Number(r.total)||0}}function U(e,t){let n=t.filter(t=>t.krTaskId===e),r=n.filter(e=>e.status===`done`).length,i=n.length,a=i===0?0:Math.round(r/i*100),o=n.map(e=>e.title),s=new Map;for(let e of n)s.set(e.status,(s.get(e.status)??0)+1);return{count:i,done:r,progress:a,titles:o,summary:i===0?`暂无待办`:[...s.entries()].map(([e,t])=>`${x[e]??e} ${t}`).join(` · `)}}function ge(e,t,n){let r=t.filter(t=>t.objectiveId===e);if(!r.length)return 0;let i=r.reduce((e,t)=>e+U(t.id,n).progress,0);return Math.round(i/r.length)}function _e(e,t){return t.filter(t=>t.objectiveId===e).map(e=>e.title)}function ve(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.title.toLowerCase().includes(n)||(e.note??``).toLowerCase().includes(n)):e}var W=h(),ye=8e3;function be(){return a(`life`)}function xe(){let[e,t]=(0,_.useState)(!1),[a,o]=(0,_.useState)(()=>r(`life`));return(0,_.useEffect)(()=>{let e=!0,a=i(()=>o(r(`life`)));return n().then(()=>{e&&(o(r(`life`)),t(!0))}),()=>{e=!1,a()}},[]),{ready:e,on:a}}function Se(e){let[t,n]=(0,_.useState)(I),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(!0),[s,c]=(0,_.useState)(``),l=(0,_.useRef)(!0),u=(0,_.useCallback)(async(e=!1)=>{e||o(!0);try{let e=await H();return l.current?(n(e),i(!0),c(``),e):null}catch(e){return l.current&&c(e instanceof Error?e.message:String(e)),null}finally{l.current&&!e&&o(!1)}},[]),d=(0,_.useCallback)(async(e,t)=>{let n=await pe(e,t);return await u(!0),n},[u]),f=(0,_.useCallback)(async(e,t,n)=>{await me(e,t,n),await u(!0)},[u]),p=(0,_.useCallback)(async(e,t)=>{await he(e,t),await u(!0)},[u]);return(0,_.useEffect)(()=>{if(!e){o(!1);return}l.current=!0;let t=null;return(async()=>{try{let e=await fe();if(!l.current)return;if(!e.ok){i(!1),o(!1);return}if(await u(),!l.current)return;i(!0),t=window.setInterval(()=>void u(!0),ye)}catch{if(!l.current)return;i(!1),o(!1)}})(),()=>{l.current=!1,t!==null&&window.clearInterval(t)}},[e,u]),{store:t,live:r,loading:a,error:s,setError:c,reload:u,createItems:d,updateItem:f,deleteItems:p}}function Ce(e){let[t,n]=(0,_.useState)(()=>l(e));return[t,(0,_.useCallback)(t=>{n(t),u(e,t)},[e])]}function we(e,t,n){let[r,i]=(0,_.useState)(()=>s(e,t,n));return[r,(0,_.useCallback)(t=>{i(t),c(e,t)},[e])]}function Te(e){let[t,n]=(0,_.useState)({}),r=(0,_.useMemo)(()=>new Set(e),[e]);(0,_.useEffect)(()=>{n(e=>{let t=!1,n={};for(let[i,a]of Object.entries(e))r.has(i)&&a?n[i]=!0:a&&(t=!0);return t||Object.keys(n).length!==Object.keys(e).length?n:e})},[r]);let i=(0,_.useMemo)(()=>Object.keys(t).filter(e=>t[e]),[t]),a=e.length>0&&e.every(e=>t[e]);function o(e){n(t=>({...t,[e]:!t[e]}))}function s(){n(t=>{let n={...t},r=!a;for(let t of e)n[t]=r;return n})}function c(){n({})}return{selected:t,selectedIds:i,allVisibleSelected:a,toggle:o,toggleAllVisible:s,clear:c}}function G(e){return e.items?e.items.length:(e.children??[]).reduce((e,t)=>e+G(t),0)}function K(e,t){let n=[],r=(e,i)=>{for(let a of e){let e=!!a.children?.length,o=G(a);if(o===0&&e||o===0&&a.items===void 0)continue;let s=!t[a.key];n.push({key:a.key,label:a.label,pill:a.pill,depth:i,count:o,kind:e?`section`:`tag`,items:e||!s?void 0:a.items??[]}),s&&e&&r(a.children,i+1)}};return r(e,0),n}function Ee(e,t){return K(e,t).flatMap(e=>e.items?e.items.map(e=>e.id):[])}function q(e=!1){return 36+(e?28:0)}function J(e=!1){return{"--tw-sticky-left":`${q(e)}px`}}J(!1);var De=`relative px-2 py-2 text-left text-xs font-medium whitespace-nowrap text-stone-500`,Oe=`relative border-l border-stone-200/90 px-2 py-2 text-left text-xs font-medium whitespace-nowrap text-stone-500`,Y=new Set([`select`,`title`,`filler`,`action`]);function ke(e){let t=(e??``).trim();if(!t)return`—`;let n=Date.parse(t);if(!Number.isFinite(n)){let e=t.slice(0,10);return/^\d{4}-\d{2}-\d{2}$/.test(e)?e.replace(/-/g,`/`):`—`}let r=new Date(n);return`${r.getFullYear()}/${String(r.getMonth()+1).padStart(2,`0`)}/${String(r.getDate()).padStart(2,`0`)} ${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`}function Ae(e,t){let n=(0,_.useMemo)(()=>new Set(t.map(e=>e.key)),[t]),[r,i]=(0,_.useState)(()=>{let t=d(e,[]);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&n.has(e)):[]});return(0,_.useEffect)(()=>{i(e=>{let t=e.filter(e=>n.has(e));return t.length===e.length?e:t})},[n]),{isVisible:(0,_.useCallback)(e=>Y.has(e)||!n.has(e)?!0:!r.includes(e),[n,r]),toggle:(0,_.useCallback)(t=>{!Y.has(t)&&n.has(t)&&i(n=>{let r=n.includes(t)?n.filter(e=>e!==t):[...n,t];return o(e,r),r})},[n,e]),hidden:r,fields:t}}function je(e,t){return e.filter(e=>t(e.key))}function Me(e){let[t,n]=(0,_.useState)(!1),r=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!t)return;function e(e){r.current?.contains(e.target)||n(!1)}function i(e){e.key===`Escape`&&n(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,i)}},[t]),(0,W.jsxs)(`div`,{ref:r,className:`relative`,children:[(0,W.jsxs)(`button`,{type:`button`,"aria-label":`字段配置`,"aria-expanded":t,onClick:()=>n(e=>!e),className:`flex h-9 items-center gap-1.5 rounded-lg border px-2.5 text-sm transition-colors ${t?`border-[#3370ff]/40 bg-[#e1eaff] text-[#1f4ec2]`:`border-stone-200 text-stone-600 hover:bg-stone-50 hover:text-stone-800`}`,children:[(0,W.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`15`,height:`15`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,W.jsx)(`path`,{d:`M4 6h16M4 12h10M4 18h14`})}),`字段`]}),t?(0,W.jsxs)(`div`,{className:`tw-select-menu absolute right-0 z-80 mt-1 w-52 overflow-hidden rounded-lg bg-white p-1 shadow-lg ring-1 ring-stone-200`,children:[(0,W.jsx)(`div`,{className:`px-2.5 py-1.5 text-[11px] font-medium tracking-wide text-stone-400`,children:`显示字段`}),e.fields.map(t=>{let n=e.isVisible(t.key);return(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-stone-700 hover:bg-stone-50`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggle(t.key),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.label})]},t.key)})]}):null]})}var Ne=`tw-sticky-l px-0 py-1 align-middle`,X=`tw-sticky-l px-0 py-2 text-left font-medium whitespace-nowrap`,Pe=`h-8 w-full justify-start rounded-md border border-stone-200 bg-white px-2 text-left text-sm font-normal text-stone-400 hover:border-stone-300 focus:ring-2 focus:ring-[#3370ff]/30`,Fe=`h-8 w-full justify-start bg-transparent px-0 text-left focus:ring-0`,Ie=`未选择`,Le=`未关联`,Re=`未设置年度`;function ze(e){return(0,W.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform duration-200 ease-out ${e.open?`rotate-0`:`-rotate-90`}`,children:(0,W.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}function Be(e){let t=(e.depth??0)>0,n=e.selectColPx??36;e.kind;let r=(0,W.jsx)(`span`,{className:`max-w-[min(100%,16rem)] truncate rounded-full px-2.5 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),i=(0,W.jsxs)(`span`,{className:`shrink-0 text-xs text-stone-400 tabular-nums`,children:[e.count,` 条记录`]}),a=(0,W.jsx)(`span`,{className:`flex h-7 w-9 shrink-0 items-center justify-center`,children:(0,W.jsx)(ze,{open:e.open})});if(!t){let t=Math.max(0,e.colSpan-2);return(0,W.jsxs)(`tr`,{role:`button`,tabIndex:0,"aria-expanded":e.open,"aria-label":e.open?`收起分组`:`展开分组`,className:`tw-life-group-head cursor-pointer bg-white`,style:{"--tw-row-bg":`#ffffff`,"--life-select-w":`${n}px`},onClick:e.onToggle,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onToggle())},children:[(0,W.jsx)(`td`,{colSpan:2,className:`tw-sticky-l tw-life-group-sticky-lead border-b border-stone-100 px-0 pb-1.5 pt-3 align-middle`,style:{left:0,"--tw-sticky-left":`0px`},children:(0,W.jsxs)(`div`,{className:`flex w-full items-center gap-2 py-1.5 pr-2 text-left`,children:[a,r,i]})}),t>0?(0,W.jsx)(`td`,{colSpan:t,className:`border-b border-stone-100 bg-white pb-1.5 pt-3`,"aria-hidden":`true`}):null]})}let o=Math.max(0,e.colSpan-2);return(0,W.jsxs)(`tr`,{role:`button`,tabIndex:0,"aria-expanded":e.open,"aria-label":e.open?`收起分组`:`展开分组`,className:`tw-life-group-head cursor-pointer bg-white`,style:{"--tw-row-bg":`#ffffff`,"--life-select-w":`${n}px`},onClick:e.onToggle,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onToggle())},children:[(0,W.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-lead border-b border-stone-100 px-0 py-0.5 align-middle`,style:{left:0,width:n,minWidth:n,maxWidth:n,"--tw-sticky-left":`0px`},children:(0,W.jsxs)(`div`,{className:`flex w-full items-center py-1.5`,children:[(0,W.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}),a]})}),(0,W.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-label border-b border-stone-100 px-2 py-0.5 align-middle`,style:{left:n,"--tw-sticky-left":`${n}px`},children:(0,W.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 py-1.5 text-left`,children:[r,i]})}),o>0?(0,W.jsx)(`td`,{colSpan:o,className:`border-b border-stone-100 bg-white py-0.5`,"aria-hidden":`true`}):null]})}function Ve(e){let t=(e.depth??0)>0,n=e.selectColPx??36,r=Math.max(0,e.colSpan-2);return(0,W.jsxs)(`tr`,{className:`tw-life-group-body`,style:{"--life-select-w":`${n}px`},children:[(0,W.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-lead px-0 py-0.5 align-middle`,style:{left:0,width:n,minWidth:n,maxWidth:n,"--tw-sticky-left":`0px`},children:(0,W.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,"aria-label":`新增记录`,className:`flex w-full items-center py-0.5 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[t?(0,W.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}):null,(0,W.jsx)(`span`,{className:`flex h-7 w-9 shrink-0 items-center justify-center text-sm leading-none`,children:`+`})]})}),(0,W.jsx)(`td`,{className:`tw-sticky-l tw-life-group-sticky-label px-2 py-0.5 align-middle`,style:{left:n,"--tw-sticky-left":`${n}px`},children:(0,W.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,className:`rounded py-0.5 text-xs text-stone-400 transition-colors hover:text-stone-600 disabled:opacity-40`,children:`新增记录`})}),r>0?(0,W.jsx)(`td`,{colSpan:r,className:`bg-white py-0.5`,"aria-hidden":`true`}):null]})}var He=`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] disabled:opacity-50`;function Ue(e){let t=(0,_.useRef)(e.row);t.current=e.row;let n=(0,_.useRef)(e.submitting);n.current=e.submitting;let r=(0,_.useRef)(e.onSubmit);r.current=e.onSubmit;let i=(0,_.useRef)(e.isPristine);i.current=e.isPristine;let a=(0,_.useRef)(e.setRow);a.current=e.setRow;let o=(0,_.useCallback)(async()=>{let e=t.current;if(!e||n.current)return;let i=e.title.trim();i&&await r.current({...e,title:i})},[]);return(0,_.useEffect)(()=>{if(e.row==null)return;let n=e=>{let n=e.target;if(!(n instanceof Element)||n.closest(`.tw-new-row`)||n.closest(`.tw-select-menu`)||n.closest(`.tw-date-panel`)||n.closest(`.tw-confirm-dialog`)||n.closest(`[data-headlessui-portal]`))return;let r=t.current;r&&(r.title.trim()?o():i.current(r)&&a.current(null))};return document.addEventListener(`pointerdown`,n,!0),()=>document.removeEventListener(`pointerdown`,n,!0)},[e.row,o]),{submit:o}}function We(e){let t=Math.max(0,Math.min(100,Math.round(e.value)));return(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5 ${e.className??``}`,children:[(0,W.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,W.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff]`,style:{width:`${t}%`}})}),(0,W.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[t,`%`]})]})}function Ge(e){let t=Math.max(0,Math.min(100,Math.round(e.value)));return(0,W.jsxs)(`div`,{className:`flex items-center gap-2.5 ${e.className??``}`,children:[(0,W.jsxs)(`div`,{className:`relative flex h-6 min-w-0 flex-1 items-center`,children:[(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 h-1.5 overflow-hidden rounded-full bg-stone-100`,"aria-hidden":`true`,children:(0,W.jsx)(`div`,{className:`h-full rounded-full bg-[#3370ff] transition-[width] duration-75`,style:{width:`${t}%`}})}),(0,W.jsx)(`input`,{type:`range`,min:0,max:100,value:t,"aria-label":e.ariaLabel??`进度`,onChange:t=>e.onChange(Number(t.target.value)),onMouseUp:t=>e.onCommit?.(Number(t.target.value)),onTouchEnd:t=>e.onCommit?.(Number(t.target.value)),onKeyUp:t=>{(t.key===`ArrowLeft`||t.key===`ArrowRight`||t.key===`Home`||t.key===`End`)&&e.onCommit?.(Number(t.target.value))},className:`tw-life-range relative z-1 w-full`})]}),(0,W.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs tabular-nums text-stone-500`,children:[t,`%`]})]})}function Ke(e){let t=(0,_.useRef)(null);return(0,_.useEffect)(()=>{t.current&&(t.current.indeterminate=!!e.indeterminate&&!e.checked)},[e.checked,e.indeterminate]),(0,W.jsx)(`th`,{className:X,"aria-label":`全选`,children:(0,W.jsxs)(`div`,{className:`flex items-center`,children:[e.nested?(0,W.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}):null,(0,W.jsx)(`div`,{className:`flex h-7 w-9 items-center justify-center`,children:(0,W.jsx)(`input`,{ref:t,type:`checkbox`,checked:e.checked,onChange:e.onChange,"aria-label":`全选`,className:`h-3.5 w-3.5 rounded border-stone-300 text-[#3370ff] focus:ring-[#3370ff]/30`})})]})})}function qe(e){let t=!!(e.selecting||e.checked),n=(e.depth??0)>0;return(0,W.jsx)(`td`,{className:Ne,children:(0,W.jsxs)(`div`,{className:`flex items-center`,children:[n?(0,W.jsx)(`span`,{className:`inline-block shrink-0`,style:{width:28},"aria-hidden":`true`}):null,(0,W.jsxs)(`div`,{className:`relative flex h-7 w-9 shrink-0 items-center justify-center`,children:[(0,W.jsx)(`span`,{className:`text-xs tabular-nums text-stone-400 transition-opacity ${t?`opacity-0`:`opacity-100 group-hover/row:opacity-0`}`,children:e.index}),(0,W.jsx)(`input`,{type:`checkbox`,checked:e.checked,onChange:e.onChange,"aria-label":e.label,className:`absolute h-3.5 w-3.5 rounded border-stone-300 text-[#3370ff] focus:ring-[#3370ff]/30 transition-opacity ${t?`opacity-100`:`opacity-0 group-hover/row:opacity-100`}`})]})]})})}function Je(e){return(0,W.jsxs)(ee,{open:e.open,onClose:e.onClose,transition:!0,className:`relative z-100`,children:[(0,W.jsx)(m,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25 duration-[280ms]`,"aria-hidden":`true`}),(0,W.jsx)(`div`,{className:`fixed inset-0 flex justify-end overflow-hidden`,children:(0,W.jsxs)(f,{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 duration-[280ms]`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,W.jsx)(p,{className:`text-base font-semibold text-stone-900`,children:e.title}),(0,W.jsx)(`button`,{type:`button`,onClick:e.onClose,"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,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:e.children}),e.footer?(0,W.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-4`,children:e.footer}):null]})})]})}function Ye(e){return(0,W.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,"aria-label":e.label,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700 disabled:opacity-40`,children:(0,W.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,W.jsx)(`path`,{d:`M15 3h6v6`}),(0,W.jsx)(`path`,{d:`M9 21H3v-6`}),(0,W.jsx)(`path`,{d:`M21 3l-7 7`}),(0,W.jsx)(`path`,{d:`M3 21l7-7`})]})})}function Xe(e){return[...e].sort((e,t)=>{let n=e.updatedAt||e.createdAt||``;return(t.updatedAt||t.createdAt||``).localeCompare(n)})}function Ze(e){return[...e].sort((e,t)=>{let n=e.createdAt||``,r=t.createdAt||``;return n===r?String(e.id||``).localeCompare(String(t.id||``)):n.localeCompare(r)})}function Qe(e,t){let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,r)=>{let i=n.get(e.status??``)??t.length,a=n.get(r.status??``)??t.length;if(i!==a)return i-a;let o=e.createdAt||``,s=r.createdAt||``;return o===s?String(e.id||``).localeCompare(String(r.id||``)):o.localeCompare(s)})}function $e(e,t){return e.objectives.find(e=>e.id===t)}var et={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,overdue:`bg-[#fee4e3] text-[#c02a26]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,stalled:`bg-[#fff7d6] text-[#8a6100]`,closed:`bg-stone-100 text-stone-400`},tt={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,overdue:`bg-[#f54a45]`,done:`bg-[#34c724]`,stalled:`bg-[#f7ba1e]`,closed:`bg-stone-300`},nt={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,incomplete:`bg-[#fff1e3] text-[#a85b00]`,closed:`bg-stone-100 text-stone-400`},rt={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,incomplete:`bg-[#ff8800]`,closed:`bg-stone-300`},it={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,incomplete:`bg-[#fff1e3] text-[#a85b00]`,done:`bg-[#d9f5d2] text-[#1d7a12]`},at={in_progress:`bg-[#3370ff]`,incomplete:`bg-[#ff8800]`,done:`bg-[#34c724]`},ot={urgent_important:`bg-[#fee4e3] text-[#c02a26]`,important:`bg-[#fff1e3] text-[#a85b00]`,urgent:`bg-[#fff7d6] text-[#8a6100]`,normal:`bg-stone-100 text-stone-600`,"":`bg-stone-50 text-stone-400`},st={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`},ct={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},Z=[{cell:`bg-[#e1eaff] text-[#1f4ec2]`,pill:`bg-[#3370ff] text-white`},{cell:`bg-[#d9f5d2] text-[#1d7a12]`,pill:`bg-[#34c724] text-white`},{cell:`bg-[#fff1e3] text-[#a85b00]`,pill:`bg-[#ff8800] text-white`},{cell:`bg-[#e0f2fe] text-[#0369a1]`,pill:`bg-[#0ea5e9] text-white`},{cell:`bg-[#fce7f3] text-[#9d174d]`,pill:`bg-[#db2777] text-white`},{cell:`bg-[#ecfdf5] text-[#047857]`,pill:`bg-[#10b981] text-white`},{cell:`bg-[#fff7d6] text-[#8a6100]`,pill:`bg-[#f7ba1e] text-stone-800`},{cell:`bg-[#fee4e3] text-[#c02a26]`,pill:`bg-[#f54a45] text-white`}],lt={cell:`bg-stone-50 text-stone-400`,pill:`bg-stone-300 text-stone-600`};function ut(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return t}function Q(e){return e.trim()?Z[ut(e)%Z.length].cell:lt.cell}function dt(e){return!e.id.trim()||!e.label.trim()||e.label===`—`?(0,W.jsx)(`span`,{className:`text-sm text-stone-300`,children:e.emptyLabel??`—`}):(0,W.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center rounded-md px-2 text-xs font-medium ${Q(e.id)}`,children:(0,W.jsx)(g,{text:e.label,className:`block min-w-0 truncate`})})}var ft=`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 $(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,W.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:`${ft} ${r&&!t?`text-stone-300`:``}`})}function pt(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,_.useState)(!1);return a?(0,W.jsx)($,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,W.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`flex h-8 w-full min-w-0 items-center rounded-md border border-transparent px-1.5 text-left text-sm text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:(0,W.jsx)(g,{text:t||`—`,className:`block min-w-0 truncate ${t?``:`text-stone-300`}`})})}function mt(e){return(0,W.jsx)(te,{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 ht(e){return(0,W.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":e.label??`正在加载`,children:(0,W.jsx)(`div`,{className:`flex min-h-[240px] flex-1 items-center justify-center`,children:(0,W.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}function gt(e){return(0,W.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:e.children})}function _t(e){return(0,W.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,"aria-label":e.label,className:`tw-icon-danger rounded p-1`,children:(0,W.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,W.jsx)(`path`,{d:`M3 6h18`}),(0,W.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,W.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,W.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})}function vt(e){return(0,W.jsx)(g,{text:e.text,className:`block min-w-0 truncate px-1.5 text-sm ${e.muted?`text-stone-300`:`text-stone-600`}`})}function yt(e){return e.error?(0,W.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,W.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.error}),(0,W.jsx)(`button`,{type:`button`,onClick:e.onDismiss,"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}export{Te as $,Ke as A,Q as B,Me as C,N as Ct,We as D,gt as E,at as F,Ze as G,q as H,Ee as I,we as J,Qe as K,je as L,vt as M,$ as N,Ge as O,it as P,xe as Q,K as R,Ye as S,de as St,ht as T,J as U,be as V,$e as W,Ue as X,Ae as Y,Ce as Z,Ve as _,_e as _t,tt as a,re as at,Je as b,S as bt,He as c,A as ct,st as d,se as dt,Se as et,De as f,P as ft,Re as g,T as gt,Ie as h,U as ht,et as i,x as it,pt as j,qe as k,ot as l,k as lt,Le as m,F as mt,nt as n,oe as nt,Pe as o,ce as ot,Oe as p,ve as pt,Xe as q,rt as r,ne as rt,Fe as s,ae as st,mt as t,y as tt,ct as u,b as ut,dt as v,ge as vt,Be as w,w as wt,yt as x,ue as xt,_t as y,C as yt,ke as z};